Skip to content

Commit 9897557

Browse files
committed
BUG: Accept list-like color with single col in plot
Close #3486
1 parent 02eafaf commit 9897557

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

doc/source/whatsnew/v0.20.1.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ I/O
5454
Plotting
5555
^^^^^^^^
5656

57-
57+
- Bug in ``DataFrame.plot`` with a single column and a list-like ``color`` (:issue:`3486`)
5858

5959

6060
Groupby/Resample/Rolling

pandas/plotting/_core.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ def _validate_color_args(self):
180180
colors = self.kwds.pop('colors')
181181
self.kwds['color'] = colors
182182

183-
if ('color' in self.kwds and self.nseries == 1):
183+
if ('color' in self.kwds and self.nseries == 1 and
184+
not is_list_like(self.kwds['color'])):
184185
# support series.plot(color='green')
185186
self.kwds['color'] = [self.kwds['color']]
186187

pandas/tests/plotting/test_frame.py

+5
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ def test_mpl2_color_cycle_str(self):
152152
else:
153153
pytest.skip("not supported in matplotlib < 2.0.0")
154154

155+
def test_color_single_series_list(self):
156+
# GH 3486
157+
df = DataFrame({"A": [1, 2, 3]})
158+
_check_plot_works(df.plot, color=['red'])
159+
155160
def test_color_empty_string(self):
156161
df = DataFrame(randn(10, 2))
157162
with pytest.raises(ValueError):

0 commit comments

Comments
 (0)