From 0873721d082bd20b2947482a0dd50f11dea864d0 Mon Sep 17 00:00:00 2001 From: Kevin Ford Date: Wed, 14 Jun 2017 23:03:03 -0700 Subject: [PATCH 1/5] Add test --- pandas/tests/plotting/test_frame.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index ba674e10be384..01f7bc94567a0 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -158,6 +158,11 @@ def test_color_single_series_list(self): df = DataFrame({"A": [1, 2, 3]}) _check_plot_works(df.plot, color=['red']) + def test_rgb_tuple_color(self): + # GH 16695 + df = DataFrame({'x': [1, 2], 'y': [3, 4]}) + _check_plot_works(df.plot, x='x', y='y', color=(1, 0, 0)) + def test_color_empty_string(self): df = DataFrame(randn(10, 2)) with pytest.raises(ValueError): From 4e40100d737d9736a3d90ade2342e4ad343d1fb6 Mon Sep 17 00:00:00 2001 From: Kevin Ford Date: Wed, 14 Jun 2017 23:04:19 -0700 Subject: [PATCH 2/5] Pass tuples that are RGB or RGBA like in list --- pandas/plotting/_core.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pandas/plotting/_core.py b/pandas/plotting/_core.py index 391fa377f3c6f..f8e83aea03594 100644 --- a/pandas/plotting/_core.py +++ b/pandas/plotting/_core.py @@ -187,6 +187,11 @@ def _validate_color_args(self): # support series.plot(color='green') self.kwds['color'] = [self.kwds['color']] + if ('color' in self.kwds and isinstance(self.kwds['color'], tuple) and + self.nseries == 1 and len(self.kwds['color']) in (3, 4)): + # support RGB and RGBA tuples in series plot + self.kwds['color'] = [self.kwds['color']] + if ('color' in self.kwds or 'colors' in self.kwds) and \ self.colormap is not None: warnings.warn("'color' and 'colormap' cannot be used " From 9fa99716f4ff55c7617ac05758df0135f61bd068 Mon Sep 17 00:00:00 2001 From: Kevin Ford Date: Wed, 14 Jun 2017 23:16:06 -0700 Subject: [PATCH 3/5] Update what's new --- doc/source/whatsnew/v0.20.3.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.20.3.txt b/doc/source/whatsnew/v0.20.3.txt index 249e05623a27f..87ecedda8eec6 100644 --- a/doc/source/whatsnew/v0.20.3.txt +++ b/doc/source/whatsnew/v0.20.3.txt @@ -59,7 +59,7 @@ I/O Plotting ^^^^^^^^ - +- Allow series plots to accept RGB and RGBA tuples as color arguments (:issue:`16233`) From 1d7767c845f7bf135da4d103e639d54e7aad67d8 Mon Sep 17 00:00:00 2001 From: Kevin Ford Date: Thu, 15 Jun 2017 07:38:08 -0700 Subject: [PATCH 4/5] change whatsnew to reflect regression fix --- doc/source/whatsnew/v0.20.3.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v0.20.3.txt b/doc/source/whatsnew/v0.20.3.txt index 87ecedda8eec6..acd19a8b8da10 100644 --- a/doc/source/whatsnew/v0.20.3.txt +++ b/doc/source/whatsnew/v0.20.3.txt @@ -59,7 +59,7 @@ I/O Plotting ^^^^^^^^ -- Allow series plots to accept RGB and RGBA tuples as color arguments (:issue:`16233`) +- Fix regression in series plotting that prevented RGB and RGBA tuples from being used as color arguments (:issue:`16233`) From d61d17aa269176bfd4fd0aa5892f74950070a43d Mon Sep 17 00:00:00 2001 From: Kevin Ford Date: Thu, 15 Jun 2017 07:38:33 -0700 Subject: [PATCH 5/5] Add test for RGBA as well --- pandas/tests/plotting/test_frame.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/plotting/test_frame.py b/pandas/tests/plotting/test_frame.py index 01f7bc94567a0..fc9ef132b2754 100644 --- a/pandas/tests/plotting/test_frame.py +++ b/pandas/tests/plotting/test_frame.py @@ -162,6 +162,7 @@ def test_rgb_tuple_color(self): # GH 16695 df = DataFrame({'x': [1, 2], 'y': [3, 4]}) _check_plot_works(df.plot, x='x', y='y', color=(1, 0, 0)) + _check_plot_works(df.plot, x='x', y='y', color=(1, 0, 0, 0.5)) def test_color_empty_string(self): df = DataFrame(randn(10, 2))