Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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/v2.1.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ Period

Plotting
^^^^^^^^
-
- Bug in :meth:`Series.plot` when invoked with ``color=None`` (:issue:`51953`)
-

Groupby/resample/rolling
Expand Down
1 change: 1 addition & 0 deletions pandas/plotting/_matplotlib/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ def _validate_color_args(self):
if (
"color" in self.kwds
and self.nseries == 1
and self.kwds["color"] is not None
and not is_list_like(self.kwds["color"])
):
# support series.plot(color='green')
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/plotting/frame/test_frame_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,3 +659,10 @@ def test_invalid_colormap(self):
msg = "(is not a valid value)|(is not a known colormap)"
with pytest.raises((ValueError, KeyError), match=msg):
df.plot(colormap="invalid_colormap")

def test_dataframe_none_color(self):
# GH51953
df = DataFrame([[1, 2, 3]])
ax = df.plot(color=None)
expected = self._unpack_cycler(self.plt.rcParams)[:3]
self._check_colors(ax.get_lines(), linecolors=expected)
7 changes: 7 additions & 0 deletions pandas/tests/plotting/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,3 +848,10 @@ def test_timedelta_index(self, index):
xlims = (3, 1)
ax = Series([1, 2], index=index).plot(xlim=(xlims))
assert ax.get_xlim() == (3, 1)

def test_series_none_color(self):
# GH51953
series = Series([1, 2, 3])
ax = series.plot(color=None)
expected = self._unpack_cycler(self.plt.rcParams)[:1]
self._check_colors(ax.get_lines(), linecolors=expected)