8000 Merge pull request #1416 from efiring/mdboom-transparent_pdf_markers · matplotlib/matplotlib@4ed5a8c · GitHub
[go: up one dir, main page]

Skip to content

Commit 4ed5a8c

Browse files
committed
Merge pull request #1416 from efiring/mdboom-transparent_pdf_markers
backend_pdf: optional rgbFace arg in fillp replaces code in draw_markers. Closes #1410
2 parents 4fad114 + 364a2a5 commit 4ed5a8c

File tree

5 files changed

+310
-5
lines changed

5 files changed

+310
-5
lines changed

lib/matplotlib/backends/backend_pdf.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ def draw_markers(self, gc, marker_path, marker_trans, path, trans, rgbFace=None)
15561556
return
15571557

15581558
self.check_gc(gc, rgbFace)
1559-
fillp = gc.fillp()
1559+
fillp = gc.fillp(rgbFace)
15601560
strokep = gc.strokep()
15611561

15621562
output = self.file.output
@@ -2002,13 +2002,20 @@ def strokep(self):
20022002
return (self._linewidth > 0 and self._alpha > 0 and
20032003
(len(self._rgb) <= 3 or self._rgb[3] != 0.0))
20042004

2005-
def fillp(self):
2005+
def fillp(self, *args):
20062006
"""
20072007
Predicate: does the path need to be filled?
2008+
2009+
An optional argument can be used to specify an alternative
2010+
_fillcolor, as needed by RendererPdf.draw_markers.
20082011
"""
2009-
return self._hatch or \
2010-
(self._fillcolor is not None and
2011-
(len(self._fillcolor) <= 3 or self._fillcolor[3] != 0.0))
2012+
if len(args):
2013+
_fillcolor = args[0]
2014+
else:
2015+
_fillcolor = self._fillcolor
2016+
return (self._hatch or
2017+
(_fillcolor is not None and
2018+
(len(_fillcolor) <= 3 or _fillcolor[3] != 0.0)))
20122019

20132020
def close_and_paint(self):
20142021
"""
Binary file not shown.
Loading
Lines changed: 289 additions & 0 deletions
Loading

lib/matplotlib/tests/test_axes.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,15 @@ def test_hist_stacked_weighted():
901901
ax = fig.add_subplot(111)
902902
ax.hist( (d1, d2), weights=(w1,w2), histtype="stepfilled", stacked=True)
903903

904+
@image_comparison(baseline_images=['transparent_markers'], remove_text=True)
905+
def test_transparent_markers():
906+
np.random.seed(0)
907+
data = np.random.random(50)
908+
909+
fig = plt.figure()
910+
ax = fig.add_subplot(111)
911+
ax.plot(data, 'D', mfc='none', markersize=100)
912+
904913
if __name__=='__main__':
905914
import nose
906915
nose.runmodule(argv=['-s','--with-doctest'], exit=False)

0 commit comments

Comments
 (0)
0