Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf40e89

Browse files
authored
Merge pull request #21697 from anntzer/psrealg
Drop non-significant zeros from ps output.
2 parents e0b02eb + 3f25bd9 commit bf40e89

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ def create_hatch(self, hatch):
385385
386386
/PaintProc {{
387387
pop
388-
{linewidth:f} setlinewidth
388+
{linewidth:g} setlinewidth
389389
{self._convert_path(
390390
Path.hatch(hatch), Affine2D().scale(sidelen), simplify=False)}
391391
gsave
@@ -395,7 +395,7 @@ def create_hatch(self, hatch):
395395
}} bind
396396
>>
397397
matrix
398-
0.0 {pageheight:f} translate
398+
0 {pageheight:g} translate
399399
makepattern
400400
/{name} exch def
401401
""")
@@ -472,9 +472,9 @@ def draw_image(self, gc, x, y, im, transform=None):
472472
self._pswriter.write(f"""\
473473
gsave
474474
{self._get_clip_cmd(gc)}
475-
{x:f} {y:f} translate
475+
{x:g} {y:g} translate
476476
[{matrix}] concat
477-
{xscale:f} {yscale:f} scale
477+
{xscale:g} {yscale:g} scale
478478
/DataString {w:d} string def
479479
{w:d} {h:d} 8 [ {w:d} 0 0 -{h:d} 0 {h:d} ]
480480
{{
@@ -674,13 +674,13 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
674674
ps_name = (font.postscript_name
675675
.encode("ascii", "replace").decode("ascii"))
676676
self.set_font(ps_name, prop.get_size_in_points())
677-
thetext = "\n".join(f"{x:f} 0 m /{name:s} glyphshow"
677+
thetext = "\n".join(f"{x:g} 0 m /{name:s} glyphshow"
678678
for x, name in xs_names)
679679
self._pswriter.write(f"""\
680680
gsave
681681
{self._get_clip_cmd(gc)}
682-
{x:f} {y:f} translate
683-
{angle:f} rotate
682+
{x:g} {y:g} translate
683+
{angle:g} rotate
684684
{thetext}
685685
grestore
686686
""")
@@ -695,8 +695,8 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
695695
self.set_color(*gc.get_rgb())
696696
self._pswriter.write(
697697
f"gsave\n"
698-
f"{x:f} {y:f} translate\n"
699-
f"{angle:f} rotate\n")
698+
f"{x:g} {y:g} translate\n"
699+
f"{angle:g} rotate\n")
700700
lastfont = None
701701
for font, fontsize, num, ox, oy in glyphs:
702702
self._character_tracker.track_glyph(font, num)
@@ -708,7 +708,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
708708
font.get_name_char(chr(num)) if isinstance(font, AFM) else
709709
font.get_glyph_name(font.get_char_index(num)))
710710
self._pswriter.write(
711-
f"{ox:f} {oy:f} moveto\n"
711+
f"{ox:g} {oy:g} moveto\n"
712712
f"/{glyph_name} glyphshow\n")
713713
for ox, oy, w, h in rects:
714714
self._pswriter.write(f"{ox} {oy} {w} {h} rectfill\n")
@@ -756,7 +756,7 @@ def draw_gouraud_triangles(self, gc, points, colors, trans):
756756
/BitsPerComponent 8
757757
/BitsPerFlag 8
758758
/AntiAlias true
759-
/Decode [ {xmin:f} {xmax:f} {ymin:f} {ymax:f} 0 1 0 1 0 1 ]
759+
/Decode [ {xmin:g} {xmax:g} {ymin:g} {ymax:g} 0 1 0 1 0 1 ]
760760
/DataSource ({stream})
761761
>>
762762
shfill

0 commit comments

Comments
 (0)