-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix line color handling #2761
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix line color handling #2761
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so, does colorConverter now handle string names of "none"? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
# some aliases.... | ||
def set_aa(self, val): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not the biggest fan of these tests (though I have written one or two myself). What would be super cool is if we could inspect the GraphicsContext for each artist and assert the facecolor is a certain value - but I suspect the current interface makes that a little hard. |
||
|
||
|
||
@image_comparison(baseline_images=['line_collection_dashes'], remove_text=True) | ||
def test_set_line_coll_dash_image(): | ||
fig = plt.figure() | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_get_rgba_in_color() can return a None, so the indexing here would break.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
gah, just now noticed you changed _get_rgba_ln_color()