MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / draw

Method draw

site-packages/matplotlib/text.py:695–762  ·  view source on GitHub ↗

Draws the `.Text` object to the given *renderer*.

(self, renderer)

Source from the content-addressed store, hash-verified

693
694 @artist.allow_rasterization
695 def draw(self, renderer):
696 """
697 Draws the `.Text` object to the given *renderer*.
698 """
699 if renderer is not None:
700 self._renderer = renderer
701 if not self.get_visible():
702 return
703 if self.get_text() == '':
704 return
705
706 renderer.open_group('text', self.get_gid())
707
708 with _wrap_text(self) as textobj:
709 bbox, info, descent = textobj._get_layout(renderer)
710 trans = textobj.get_transform()
711
712 # don't use textobj.get_position here, which refers to text
713 # position in Text, and dash position in TextWithDash:
714 posx = float(textobj.convert_xunits(textobj._x))
715 posy = float(textobj.convert_yunits(textobj._y))
716 posx, posy = trans.transform_point((posx, posy))
717 if not np.isfinite(posx) or not np.isfinite(posy):
718 _log.warning("posx and posy should be finite values")
719 return
720 canvasw, canvash = renderer.get_canvas_width_height()
721
722 # draw the FancyBboxPatch
723 if textobj._bbox_patch:
724 textobj._draw_bbox(renderer, posx, posy)
725
726 gc = renderer.new_gc()
727 gc.set_foreground(textobj.get_color())
728 gc.set_alpha(textobj.get_alpha())
729 gc.set_url(textobj._url)
730 textobj._set_gc_clip(gc)
731
732 angle = textobj.get_rotation()
733
734 for line, wh, x, y in info:
735
736 mtext = textobj if len(info) == 1 else None
737 x = x + posx
738 y = y + posy
739 if renderer.flipy():
740 y = canvash - y
741 clean_line, ismath = textobj.is_math_text(line,
742 self.get_usetex())
743
744 if textobj.get_path_effects():
745 from matplotlib.patheffects import PathEffectRenderer
746 textrenderer = PathEffectRenderer(
747 textobj.get_path_effects(), renderer)
748 else:
749 textrenderer = renderer
750
751 if textobj.get_usetex():
752 textrenderer.draw_tex(gc, x, y, clean_line,

Callers 15

plot_childrenFunction · 0.45
_draw_bboxMethod · 0.45
drawMethod · 0.45
drawMethod · 0.45
_motionMethod · 0.45
set_activeMethod · 0.45
_rendercursorMethod · 0.45
stop_typingMethod · 0.45
_motionMethod · 0.45
set_activeMethod · 0.45
funcMethod · 0.45
funcleftMethod · 0.45

Calls 15

get_textMethod · 0.95
get_usetexMethod · 0.95
PathEffectRendererClass · 0.90
_wrap_textFunction · 0.85
get_visibleMethod · 0.80
_get_layoutMethod · 0.80
convert_xunitsMethod · 0.80
convert_yunitsMethod · 0.80
_draw_bboxMethod · 0.80
_set_gc_clipMethod · 0.80
get_path_effectsMethod · 0.80
open_groupMethod · 0.45

Tested by

no test coverage detected