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

Skip to content

Commit a769d64

Browse files
authored
Merge pull request #17215 from anntzer/ps
Small cleanups.
2 parents a927a9d + c0a4874 commit a769d64

File tree

2 files changed

+8
-16
lines changed

2 files changed

+8
-16
lines changed

lib/matplotlib/backends/backend_ps.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -446,14 +446,12 @@ def draw_path_collection(self, gc, master_transform, paths, all_transforms,
446446
linewidths, linestyles, antialiaseds, urls,
447447
offset_position)
448448

449-
write = self._pswriter.write
450-
451449
path_codes = []
452450
for i, (path, transform) in enumerate(self._iter_collection_raw_paths(
453451
master_transform, paths, all_transforms)):
454452
name = 'p%x_%x' % (self._path_collection_id, i)
455453
path_bytes = self._convert_path(path, transform, simplify=False)
456-
write(f"""\
454+
self._pswriter.write(f"""\
457455
/{name} {{
458456
newpath
459457
translate
@@ -510,10 +508,8 @@ def draw_tex(self, gc, x, y, s, prop, angle, ismath='TeX!', mtext=None):
510508
def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
511509
# docstring inherited
512510

513-
# local to avoid repeated attribute lookups
514-
write = self._pswriter.write
515511
if debugPS:
516-
write("% text\n")
512+
self._pswriter.write("% text\n")
517513

518514
if _is_transparent(gc.get_rgb()):
519515
return # Special handling for fully transparent.
@@ -941,10 +937,7 @@ def print_figure_impl(fh):
941937
file=fh)
942938

943939
# write the figure
944-
content = self._pswriter.getvalue()
945-
if not isinstance(content, str):
946-
content = content.decode('ascii')
947-
print(content, file=fh)
940+
print(self._pswriter.getvalue(), file=fh)
948941

949942
# write the trailer
950943
print("end", file=fh)

lib/matplotlib/mathtext.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
r"""
2-
`~matplotlib.mathtext` is a module for parsing a subset of the
3-
TeX math syntax and drawing them to a matplotlib backend.
2+
A module for parsing a subset of the TeX math syntax and rendering it to a
3+
Matplotlib backend.
44
5-
For a tutorial of its usage see :doc:`/tutorials/text/mathtext`. This
5+
For a tutorial of its usage, see :doc:`/tutorials/text/mathtext`. This
66
document is primarily concerned with implementation details.
77
88
The module uses pyparsing_ to parse the TeX expression.
@@ -231,8 +231,7 @@ def __init__(self):
231231
def render_glyph(self, ox, oy, info):
232232
oy = self.height - oy + info.offset
233233
postscript_name = info.postscript_name
234-
fontsize = info.fontsize
235-
symbol_name = info.symbol_name
234+
fontsize = info.fontsize
236235

237236
if (postscript_name, fontsize) != self.lastfont:
238237
self.lastfont = postscript_name, fontsize
@@ -243,7 +242,7 @@ def render_glyph(self, ox, oy, info):
243242

244243
self.pswriter.write(
245244
f"{ox:f} {oy:f} moveto\n"
246-
f"/{symbol_name} glyphshow\n")
245+
f"/{info.symbol_name} glyphshow\n")
247246

248247
def render_rect_filled(self, x1, y1, x2, y2):
249248
ps = "%f %f %f %f rectfill\n" % (

0 commit comments

Comments
 (0)