Skip to content

Commit f2853bd

Browse files
committed
Fix hatching with no edges in PS backend.
Also, clean up some redundancies; 72 -> sidelen and the setpattern operator simplifies setting the pattern.
1 parent 862b747 commit f2853bd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,10 @@ def create_hatch(self, hatch):
318318
%(linewidth)f setlinewidth
319319
""" % locals())
320320
self._pswriter.write(
321-
self._convert_path(Path.hatch(hatch), Affine2D().scale(72.0),
321+
self._convert_path(Path.hatch(hatch), Affine2D().scale(sidelen),
322322
simplify=False))
323323
self._pswriter.write("""\
324-
stroke
324+
stroke
325325
} bind
326326
>>
327327
matrix
@@ -861,6 +861,7 @@ def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
861861
stroke = stroke and mightstroke
862862
fill = (fill and rgbFace is not None and
863863
(len(rgbFace) <= 3 or rgbFace[3] != 0.0))
864+
hatch = gc.get_hatch()
864865

865866
if mightstroke:
866867
self.set_linewidth(gc.get_linewidth())
@@ -886,19 +887,18 @@ def _draw_ps(self, ps, gc, rgbFace, fill=True, stroke=True, command=None):
886887
write("\n")
887888

888889
if fill:
889-
if stroke:
890+
if stroke or hatch:
890891
write("gsave\n")
891892
self.set_color(store=0, *rgbFace[:3])
892893
write("fill\n")
893-
if stroke:
894+
if stroke or hatch:
894895
write("grestore\n")
895896

896-
hatch = gc.get_hatch()
897897
if hatch:
898898
hatch_name = self.create_hatch(hatch)
899899
write("gsave\n")
900-
write("[/Pattern [/DeviceRGB]] setcolorspace %f %f %f " % gc.get_hatch_color()[:3])
901-
write("%s setcolor fill grestore\n" % hatch_name)
900+
write("%f %f %f " % gc.get_hatch_color()[:3])
901+
write("%s setpattern fill grestore\n" % hatch_name)
902902

903903
if stroke:
904904
write("stroke\n")

0 commit comments

Comments
 (0)