Skip to content

Commit c90b134

Browse files
authored
Merge pull request #22794 from matplotlib/pscoloredhatches
Fix ps export of colored hatches with no linewidth
2 parents af5199a + 9a11893 commit c90b134

File tree

3 files changed

+230
-0
lines changed

3 files changed

+230
-0
lines changed

lib/matplotlib/backends/backend_ps.py

+1
Original file line numberDiff line numberDiff line change
@@ -783,6 +783,7 @@ def _draw_ps(self, ps, gc, rgbFace, *, fill=True, stroke=True):
783783
self.set_linejoin(gc.get_joinstyle())
784784
self.set_linecap(gc.get_capstyle())
785785
self.set_linedash(*gc.get_dashes())
786+
if mightstroke or hatch:
786787
self.set_color(*gc.get_rgb()[:3])
787788
write('gsave\n')
788789

lib/matplotlib/tests/baseline_images/test_backend_ps/coloredhatcheszerolw.eps

+216
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/matplotlib/tests/test_backend_ps.py

+13
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from matplotlib import cbook, patheffects
1010
from matplotlib._api import MatplotlibDeprecationWarning
1111
from matplotlib.figure import Figure
12+
from matplotlib.patches import Ellipse
1213
from matplotlib.testing.decorators import check_figures_equal, image_comparison
1314
import matplotlib as mpl
1415
import matplotlib.pyplot as plt
@@ -192,6 +193,18 @@ def test_type3_font():
192193
plt.figtext(.5, .5, "I/J")
193194

194195

196+
@image_comparison(["coloredhatcheszerolw.eps"])
197+
def test_colored_hatch_zero_linewidth():
198+
ax = plt.gca()
199+
ax.add_patch(Ellipse((0, 0), 1, 1, hatch='/', facecolor='none',
200+
edgecolor='r', linewidth=0))
201+
ax.add_patch(Ellipse((0.5, 0.5), 0.5, 0.5, hatch='+', facecolor='none',
202+
edgecolor='g', linewidth=0.2))
203+
ax.add_patch(Ellipse((1, 1), 0.3, 0.8, hatch='\\', facecolor='none',
204+
edgecolor='b', linewidth=0))
205+
ax.set_axis_off()
206+
207+
195208
@check_figures_equal(extensions=["eps"])
196209
def test_text_clip(fig_test, fig_ref):
197210
ax = fig_test.add_subplot()

0 commit comments

Comments
 (0)