Skip to content

Commit

Permalink
Merge pull request #2761 from tacaswell/fix_line_color_handling
Browse files Browse the repository at this point in the history
Fix line color handling
  • Loading branch information
mdboom committed Jan 27, 2014
2 parents 3d297ff + cc1756a commit e807990
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
11 changes: 3 additions & 8 deletions lib/matplotlib/lines.py
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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):
Expand Down
15 changes: 14 additions & 1 deletion lib/matplotlib/tests/test_lines.py
Expand Up @@ -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.
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit e807990

Please sign in to comment.