Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -634,6 +634,7 @@ Plotting
- Bug in :meth:`.DataFrameGroupBy.boxplot` failed when there were multiple groupings (:issue:`14701`)
- Bug in :meth:`DataFrame.plot` that causes a shift to the right when the frequency multiplier is greater than one. (:issue:`57587`)
- Bug in :meth:`Series.plot` with ``kind="pie"`` with :class:`ArrowDtype` (:issue:`59192`)
- Bug in :meth:`core._validate_color_args` raising ``ValueError`` when set both color and style in plt.plot.line (:issue:`59461`)

Groupby/resample/rolling
^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
2 changes: 2 additions & 0 deletions pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ def _validate_color_args(self, color, colormap):
styles = self.style
else:
styles = [self.style]
if isinstance(self.style, dict):
styles = [self.style[col] for col in self.columns if col in self.style]
# need only a single match
for s in styles:
if _color_in_style(s):
Expand Down
12 changes: 12 additions & 0 deletions pandas/tests/plotting/frame/test_frame_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,18 @@ def test_color_and_marker(self, color, expected):
assert all(i.get_linestyle() == "--" for i in ax.lines)
assert all(i.get_marker() == "d" for i in ax.lines)

def test_color_and_style(self):
color = {"g": "black", "h": "brown"}
style = {"g": "-", "h": "--"}
expected_color = ["black", "brown"]
expected_style = ["-", "--"]
df = DataFrame({"g": [1, 2], "h": [2, 3]}, index=[1, 2])
ax = df.plot.line(color=color, style=style)
color = [i.get_color() for i in ax.lines]
style = [i.get_linestyle() for i in ax.lines]
assert color == expected_color
assert style == expected_style

def test_bar_colors(self):
default_colors = _unpack_cycler(plt.rcParams)

Expand Down