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

Skip to content

Commit abec281

Browse files
committed
Yield as textobj instead of self
1 parent 311a928 commit abec281

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

lib/matplotlib/text.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -731,57 +731,57 @@ def draw(self, renderer):
731731

732732
renderer.open_group('text', self.get_gid())
733733

734-
with _wrap_text(self) as self:
735-
bbox, info, descent = self._get_layout(renderer)
736-
trans = self.get_transform()
734+
with _wrap_text(self) as textobj:
735+
bbox, info, descent = textobj._get_layout(renderer)
736+
trans = textobj.get_transform()
737737

738-
# don't use self.get_position here, which refers to text position
739-
# in Text, and dash position in TextWithDash:
740-
posx = float(self.convert_xunits(self._x))
741-
posy = float(self.convert_yunits(self._y))
738+
# don't use textobj.get_position here, which refers to text
739+
# position in Text, and dash position in TextWithDash:
740+
posx = float(textobj.convert_xunits(textobj._x))
741+
posy = float(textobj.convert_yunits(textobj._y))
742742

743743
posx, posy = trans.transform_point((posx, posy))
744744
canvasw, canvash = renderer.get_canvas_width_height()
745745

746746
# draw the FancyBboxPatch
747-
if self._bbox_patch:
748-
self._draw_bbox(renderer, posx, posy)
747+
if textobj._bbox_patch:
748+
textobj._draw_bbox(renderer, posx, posy)
749749

750750
gc = renderer.new_gc()
751-
gc.set_foreground(self.get_color())
752-
gc.set_alpha(self.get_alpha())
753-
gc.set_url(self._url)
754-
self._set_gc_clip(gc)
751+
gc.set_foreground(textobj.get_color())
752+
gc.set_alpha(textobj.get_alpha())
753+
gc.set_url(textobj._url)
754+
textobj._set_gc_clip(gc)
755755

756-
if self._bbox:
757-
bbox_artist(self, renderer, self._bbox)
758-
angle = self.get_rotation()
756+
if textobj._bbox:
757+
bbox_artist(textobj, renderer, textobj._bbox)
758+
angle = textobj.get_rotation()
759759

760760
for line, wh, x, y in info:
761761
if not np.isfinite(x) or not np.isfinite(y):
762762
continue
763763

764-
mtext = self if len(info) == 1 else None
764+
mtext = textobj if len(info) == 1 else None
765765
x = x + posx
766766
y = y + posy
767767
if renderer.flipy():
768768
y = canvash - y
769-
clean_line, ismath = self.is_math_text(line)
769+
clean_line, ismath = textobj.is_math_text(line)
770770

771-
if self.get_path_effects():
771+
if textobj.get_path_effects():
772772
from matplotlib.patheffects import PathEffectRenderer
773-
textrenderer = PathEffectRenderer(self.get_path_effects(),
774-
renderer)
773+
textrenderer = PathEffectRenderer(
774+
textobj.get_path_effects(), renderer)
775775
else:
776776
textrenderer = renderer
777777

778-
if self.get_usetex():
778+
if textobj.get_usetex():
779779
textrenderer.draw_tex(gc, x, y, clean_line,
780-
self._fontproperties, angle,
780+
textobj._fontproperties, angle,
781781
mtext=mtext)
782782
else:
783783
textrenderer.draw_text(gc, x, y, clean_line,
784-
self._fontproperties, angle,
784+
textobj._fontproperties, angle,
785785
ismath=ismath, mtext=mtext)
786786

787787
gc.restore()

0 commit comments

Comments
 (0)