From d2a9f6bfc83dacc6f087fc50921bdf8ed99ce0a2 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 24 Jan 2014 00:24:54 -0500 Subject: [PATCH 1/2] TST : test `plot(.., color='none')` added failing test for issue #2760 --- lib/matplotlib/tests/test_lines.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_lines.py b/lib/matplotlib/tests/test_lines.py index 6eefd1e5353d..3c0821b127c7 100644 --- a/lib/matplotlib/tests/test_lines.py +++ b/lib/matplotlib/tests/test_lines.py @@ -14,7 +14,7 @@ def test_invisible_Line_rendering(): """ Github issue #1256 identified a bug in Line.draw method - + Despite visibility attribute set to False, the draw method was not returning early enough and some pre-rendering code was executed though not necessary. @@ -67,6 +67,19 @@ def test_set_line_coll_dash(): assert True +@cleanup +def test_line_colors(): + fig = plt.figure() + ax = fig.add_subplot(1, 1, 1) + ax.plot(range(10), color='none') + ax.plot(range(10), color='r') + ax.plot(range(10), color='.3') + ax.plot(range(10), color=(1, 0, 0, 1)) + ax.plot(range(10), color=(1, 0, 0)) + fig.canvas.draw() + assert True + + @image_comparison(baseline_images=['line_collection_dashes'], remove_text=True) def test_set_line_coll_dash_image(): fig = plt.figure() From cc1756a9f2f618d3501eb4449d86ee2c255579b3 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Fri, 24 Jan 2014 00:31:36 -0500 Subject: [PATCH 2/2] BUG : make `plot(..., color='none')` work again Fixes #2760 Fixes miss-handling of color conversion logic introduced in edc48f0 --- lib/matplotlib/lines.py | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/lib/matplotlib/lines.py b/lib/matplotlib/lines.py index f3176c12e671..d58276336615 100644 --- a/lib/matplotlib/lines.py +++ b/lib/matplotlib/lines.py @@ -527,7 +527,7 @@ def draw(self, renderer): self._set_gc_clip(gc) ln_color_rgba = self._get_rgba_ln_color() - gc.set_foreground(ln_color_rgba) + gc.set_foreground(ln_color_rgba, isRGBA=True) gc.set_alpha(ln_color_rgba[3]) gc.set_antialiased(self._antialiased) @@ -569,7 +569,7 @@ def draw(self, renderer): edgecolor = self.get_markeredgecolor() if is_string_like(edgecolor) and edgecolor.lower() == 'none': gc.set_linewidth(0) - gc.set_foreground(rgbaFace) + gc.set_foreground(rgbaFace, isRGBA=True) else: gc.set_foreground(edgecolor) gc.set_linewidth(self._markeredgewidth) @@ -1031,12 +1031,7 @@ def _get_rgba_face(self, alt=False): return rgbaFace def _get_rgba_ln_color(self, alt=False): - ln_color = self._color - if is_string_like(ln_color) and ln_color.lower() == 'none': - rgba_ln = None - else: - rgba_ln = colorConverter.to_rgba(ln_color, self._alpha) - return rgba_ln + return colorConverter.to_rgba(self._color, self._alpha) # some aliases.... def set_aa(self, val):