-
-
Notifications
You must be signed in to change notification settings - Fork 19.2k
BUG: fix SeriesGroupBy.plot does not respect cmap parameter #62671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! Can you also add a test.
def f(obj, color=None, label=None): | ||
plot_kwargs = dict(kwargs) | ||
if color is not None: | ||
plot_kwargs["color"] = color | ||
if label is not None: | ||
plot_kwargs["label"] = label | ||
return obj.plot(*args, **plot_kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the same as the function f
below; can you move to the top and just define once.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also rename to something meaningful; perhaps plot_group
?
if colormap is not None and color is None: | ||
from pandas.plotting._matplotlib.style import get_standard_colors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should only do this when get_option("plotting.backend") == "matplotlib"
. Can you use the previous logic for any other backend.
colormap=colormap, | ||
color_type="default", | ||
) | ||
kwargs = dict(kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this necessary?
for i, (name, group) in enumerate(self._groupby): | ||
results.append(f(group, colors[i], name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for i, (name, group) in enumerate(self._groupby): | |
results.append(f(group, colors[i], name)) | |
for name, group, color in zip(self._groupby, colors): | |
results.append(f(group, color, name)) |
SeriesGroupBy.plot
does not respectcmap
parameter #56697doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.Following screenshot is from running