Skip to content

Commit 7980460

Browse files
committed
BUG: Accept list-like color with single col in plot
Closes pandas-dev#3486
1 parent fdc2185 commit 7980460

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

doc/source/whatsnew/v0.20.2.txt

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ I/O
5555
Plotting
5656
^^^^^^^^
5757

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

5961

6062

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
@@ -153,6 +153,11 @@ def test_mpl2_color_cycle_str(self):
153153
else:
154154
pytest.skip("not supported in matplotlib < 2.0.0")
155155

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

0 commit comments

Comments
 (0)