Skip to content

Drop non-significant zeros from ps output. #21697

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
Nov 22, 2021
Merged
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
22 changes: 11 additions & 11 deletions lib/matplotlib/backends/backend_ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ def create_hatch(self, hatch):

/PaintProc {{
pop
{linewidth:f} setlinewidth
{linewidth:g} setlinewidth
{self._convert_path(
Path.hatch(hatch), Affine2D().scale(sidelen), simplify=False)}
gsave
Expand All @@ -395,7 +395,7 @@ def create_hatch(self, hatch):
}} bind
>>
matrix
0.0 {pageheight:f} translate
0 {pageheight:g} translate
makepattern
/{name} exch def
""")
Expand Down Expand Up @@ -472,9 +472,9 @@ def draw_image(self, gc, x, y, im, transform=None):
self._pswriter.write(f"""\
gsave
{self._get_clip_cmd(gc)}
{x:f} {y:f} translate
{x:g} {y:g} translate
[{matrix}] concat
{xscale:f} {yscale:f} scale
{xscale:g} {yscale:g} scale
/DataString {w:d} string def
{w:d} {h:d} 8 [ {w:d} 0 0 -{h:d} 0 {h:d} ]
{{
Expand Down Expand Up @@ -674,13 +674,13 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
ps_name = (font.postscript_name
.encode("ascii", "replace").decode("ascii"))
self.set_font(ps_name, prop.get_size_in_points())
thetext = "\n".join(f"{x:f} 0 m /{name:s} glyphshow"
thetext = "\n".join(f"{x:g} 0 m /{name:s} glyphshow"
for x, name in xs_names)
self._pswriter.write(f"""\
gsave
{self._get_clip_cmd(gc)}
{x:f} {y:f} translate
{angle:f} rotate
{x:g} {y:g} translate
{angle:g} rotate
{thetext}
grestore
""")
Expand All @@ -695,8 +695,8 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
self.set_color(*gc.get_rgb())
self._pswriter.write(
f"gsave\n"
f"{x:f} {y:f} translate\n"
f"{angle:f} rotate\n")
f"{x:g} {y:g} translate\n"
f"{angle:g} rotate\n")
lastfont = None
for font, fontsize, num, ox, oy in glyphs:
self._character_tracker.track_glyph(font, num)
Expand All @@ -708,7 +708,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
font.get_name_char(chr(num)) if isinstance(font, AFM) else
font.get_glyph_name(font.get_char_index(num)))
self._pswriter.write(
f"{ox:f} {oy:f} moveto\n"
f"{ox:g} {oy:g} moveto\n"
f"/{glyph_name} glyphshow\n")
for ox, oy, w, h in rects:
self._pswriter.write(f"{ox} {oy} {w} {h} rectfill\n")
Expand Down Expand Up @@ -756,7 +756,7 @@ def draw_gouraud_triangles(self, gc, points, colors, trans):
/BitsPerComponent 8
/BitsPerFlag 8
/AntiAlias true
/Decode [ {xmin:f} {xmax:f} {ymin:f} {ymax:f} 0 1 0 1 0 1 ]
/Decode [ {xmin:g} {xmax:g} {ymin:g} {ymax:g} 0 1 0 1 0 1 ]
/DataSource ({stream})
>>
shfill
Expand Down