Skip to content
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

VIS: Fix DataFrame.plot() produces incorrect legend markers when plotting multiple series on the same axis #27808

Merged
merged 22 commits into from
Aug 16, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion doc/source/whatsnew/v1.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ Plotting
^^^^^^^^

-
-
- Bug in :meth:`DataFrame.plot` producing incorrect legend labels when plotting multiple series on the same axis (:issue:`18222`)

Groupby/resample/rolling
^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
9 changes: 9 additions & 0 deletions pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ def __init__(
setattr(self, attr, value)

self.ax = ax

# set subplots to True if plt.subplots() uses and assign to ax
from matplotlib.axes import SubplotBase
TomAugspurger marked this conversation as resolved.
Show resolved Hide resolved
try:
TomAugspurger marked this conversation as resolved.
Show resolved Hide resolved
ax_type = isinstance(self.ax, SubplotBase)
except TypeError:
ax_type = isinstance(self.ax[0], SubplotBase)
if ax_type:
self.subplots = True
self.fig = fig
self.axes = None

Expand Down