Skip to content

Fix ps export of colored hatches with no linewidth #22794

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

Merged
merged 1 commit into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,7 @@ def _draw_ps(self, ps, gc, rgbFace, *, fill=True, stroke=True):
self.set_linejoin(gc.get_joinstyle())
self.set_linecap(gc.get_capstyle())
self.set_linedash(*gc.get_dashes())
if mightstroke or hatch:
self.set_color(*gc.get_rgb()[:3])
write('gsave\n')

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions lib/matplotlib/tests/test_backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from matplotlib import cbook, patheffects
from matplotlib._api import MatplotlibDeprecationWarning
from matplotlib.figure import Figure
from matplotlib.patches import Ellipse
from matplotlib.testing.decorators import check_figures_equal, image_comparison
import matplotlib as mpl
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -192,6 +193,18 @@ def test_type3_font():
plt.figtext(.5, .5, "I/J")


@image_comparison(["coloredhatcheszerolw.eps"])
def test_colored_hatch_zero_linewidth():
ax = plt.gca()
ax.add_patch(Ellipse((0, 0), 1, 1, hatch='/', facecolor='none',
edgecolor='r', linewidth=0))
ax.add_patch(Ellipse((0.5, 0.5), 0.5, 0.5, hatch='+', facecolor='none',
edgecolor='g', linewidth=0.2))
ax.add_patch(Ellipse((1, 1), 0.3, 0.8, hatch='\\', facecolor='none',
edgecolor='b', linewidth=0))
ax.set_axis_off()


@check_figures_equal(extensions=["eps"])
def test_text_clip(fig_test, fig_ref):
ax = fig_test.add_subplot()
Expand Down