Skip to content

Commit

Permalink
BUG: Accept list-like color with single col in plot
Browse files Browse the repository at this point in the history
Closes #3486
  • Loading branch information
TomAugspurger committed May 11, 2017
1 parent fdc2185 commit 7980460
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 2 additions & 0 deletions doc/source/whatsnew/v0.20.2.txt
Expand Up @@ -55,6 +55,8 @@ I/O
Plotting
^^^^^^^^

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




Expand Down
3 changes: 2 additions & 1 deletion pandas/plotting/_core.py
Expand Up @@ -180,7 +180,8 @@ def _validate_color_args(self):
colors = self.kwds.pop('colors')
self.kwds['color'] = colors

if ('color' in self.kwds and self.nseries == 1):
if ('color' in self.kwds and self.nseries == 1 and
not is_list_like(self.kwds['color'])):
# support series.plot(color='green')
self.kwds['color'] = [self.kwds['color']]

Expand Down
5 changes: 5 additions & 0 deletions pandas/tests/plotting/test_frame.py
Expand Up @@ -153,6 +153,11 @@ def test_mpl2_color_cycle_str(self):
else:
pytest.skip("not supported in matplotlib < 2.0.0")

def test_color_single_series_list(self):
# GH 3486
df = DataFrame({"A": [1, 2, 3]})
_check_plot_works(df.plot, color=['red'])

def test_color_empty_string(self):
df = DataFrame(randn(10, 2))
with pytest.raises(ValueError):
Expand Down

0 comments on commit 7980460

Please sign in to comment.