From 79804603b31752c86a74d9e50d9b13d50f6ab0d1 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Wed, 3 May 2017 21:07:13 -0500 Subject: [PATCH] BUG: Accept list-like color with single col in plot Closes #3486 --- doc/source/whatsnew/v0.20.2.txt | 2 ++ pandas/plotting/_core.py | 3 ++- pandas/tests/plotting/test_frame.py | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.20.2.txt b/doc/source/whatsnew/v0.20.2.txt index 983f3edfa2f46..cbfebee2ceba2 100644 --- a/doc/source/whatsnew/v0.20.2.txt +++ b/doc/source/whatsnew/v0.20.2.txt @@ -55,6 +55,8 @@ I/O Plotting ^^^^^^^^ +- Bug in ``DataFrame.plot`` with a single column and a list-like ``color`` (:issue:`3486`) + diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index e88979b14c8af..c0f9f62106330 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -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']] diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index 9abbb348fbfa8..e40ec5a1faea8 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -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):