Skip to content

Commit 050c0b1

Browse files
committed
lines.py: fix bugs in marker alpha and edge colors
Two bugs are fixed: 1) plt.plot(np.arange(3),'ro', mec='none') was not plotting anything because 'none' was setting the edgecolor alpha to 0, and that alpha was being propagated to gc, overriding the face color. The 'none' case needs to be trapped, not passed on to the GraphicsContext. 2) plt.plot(np.arange(3), 'r.') was drawing a black edge around the point; same for 'r,'; the markers.py refactoring turned the point and pixel markers into filled markers, with their default black borders. The solution here was to special-case them in Line2D. They do need to be filled, with edges of the same color; otherwise the pixel can end up nearly invisible, and the point could end up as a donut.
1 parent aa07d18 commit 050c0b1

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

lib/matplotlib/lines.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,15 @@ def draw(self, renderer):
508508
if self._marker:
509509
gc = renderer.new_gc()
510510
self._set_gc_clip(gc)
511-
gc.set_foreground(self.get_markeredgecolor())
512-
gc.set_linewidth(self._markeredgewidth)
511+
rgbFace = self._get_rgb_face()
512+
rgbFaceAlt = self._get_rgb_face(alt=True)
513+
edgecolor = self.get_markeredgecolor()
514+
if is_string_like(edgecolor) and edgecolor.lower() == 'none':
515+
gc.set_linewidth(0)
516+
gc.set_foreground(rgbFace)
517+
else:
518+
gc.set_foreground(edgecolor)
519+
gc.set_linewidth(self._markeredgewidth)
513520
gc.set_alpha(self._alpha)
514521
marker = self._marker
515522
tpath, affine = self._transformed_path.get_transformed_points_and_affine()
@@ -539,18 +546,16 @@ def draw(self, renderer):
539546
w = renderer.points_to_pixels(self._markersize)
540547
if marker.get_marker() != ',': # Don't scale for pixels
541548
marker_trans = marker_trans.scale(w)
542-
rgbFace = self._get_rgb_face()
543549
renderer.draw_markers(
544550
gc, marker_path, marker_trans, subsampled, affine.frozen(),
545551
rgbFace)
546552
alt_marker_path = marker.get_alt_path()
547553
if alt_marker_path:
548554
alt_marker_trans = marker.get_alt_transform()
549555
alt_marker_trans = alt_marker_trans.scale(w)
550-
rgbFace = self._get_rgb_face(alt=True)
551556
renderer.draw_markers(
552557
gc, alt_marker_path, alt_marker_trans, subsampled,
553-
affine.frozen(), rgbFace)
558+
affine.frozen(), rgbFaceAlt)
554559

555560
gc.restore()
556561

@@ -567,16 +572,15 @@ def get_marker(self): return self._marker.get_marker()
567572

568573
def get_markeredgecolor(self):
569574
if (is_string_like(self._markeredgecolor) and
570-
self._markeredgecolor == 'auto'):
575+
self._markeredgecolor == 'auto'):
576+
if self._marker.get_marker() in ('.', ','):
577+
return self._color
571578
if self._marker.is_filled():
572-
return 'k'
579+
return 'k' # Bad hard-wired default...
573580
else:
574581
return self._color
575-
else:
576-
return self._markeredgecolor
577-
578-
579582
return self._markeredgecolor
583+
580584
def get_markeredgewidth(self): return self._markeredgewidth
581585

582586
def _get_markerfacecolor(self, alt=False):

0 commit comments

Comments
 (0)