Skip to content

Commit 7062dda

Browse files
committed
ps: Use rectclip instead of custom clipbox
Since we require language level 2 now, we can use this directly.
1 parent e39d792 commit 7062dda

File tree

1 file changed

+3
-18
lines changed

1 file changed

+3
-18
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ def _get_clip_cmd(self, gc):
407407
clip = []
408408
rect = gc.get_clip_rectangle()
409409
if rect is not None:
410-
clip.append("%s clipbox\n" % _nums_to_str(*rect.size, *rect.p0))
410+
clip.append(f"{_nums_to_str(*rect.p0, *rect.size)} rectclip\n")
411411
path, trf = gc.get_clip_path()
412412
if path is not None:
413413
key = (path, id(trf))
@@ -953,8 +953,7 @@ def print_figure_impl(fh):
953953
print("%s translate" % _nums_to_str(xo, yo), file=fh)
954954
if rotation:
955955
print("%d rotate" % rotation, file=fh)
956-
print("%s clipbox" % _nums_to_str(width*72, height*72, 0, 0),
957-
file=fh)
956+
print(f"0 0 {_nums_to_str(width*72, height*72)} rectclip", file=fh)
958957

959958
# write the figure
960959
print(self._pswriter.getvalue(), file=fh)
@@ -1038,7 +1037,7 @@ def _print_figure_tex(
10381037
%%EndProlog
10391038
mpldict begin
10401039
{_nums_to_str(xo, yo)} translate
1041-
{_nums_to_str(width*72, height*72)} 0 0 clipbox
1040+
0 0 {_nums_to_str(width*72, height*72)} rectclip
10421041
{self._pswriter.getvalue()}
10431042
end
10441043
showpage
@@ -1316,20 +1315,6 @@ def pstoeps(tmpfile, bbox=None, rotated=False):
13161315
"/cl { closepath } _d",
13171316
# *ce* -
13181317
"/ce { closepath eofill } _d",
1319-
# w h x y *box* -
1320-
"""/box {
1321-
m
1322-
1 index 0 r
1323-
0 exch r
1324-
neg 0 r
1325-
cl
1326-
} _d""",
1327-
# w h x y *clipbox* -
1328-
"""/clipbox {
1329-
box
1330-
clip
1331-
newpath
1332-
} _d""",
13331318
# wx wy llx lly urx ury *setcachedevice* -
13341319
"/sc { setcachedevice } _d",
13351320
]

0 commit comments

Comments
 (0)