MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / TextArea

Class TextArea

lib/matplotlib/offsetbox.py:709–825  ·  view source on GitHub ↗

The TextArea is a container artist for a single Text instance. The text is placed at (0, 0) with baseline+left alignment, by default. The width and height of the TextArea instance is the width and height of its child text.

Source from the content-addressed store, hash-verified

707
708
709class TextArea(OffsetBox):
710 """
711 The TextArea is a container artist for a single Text instance.
712
713 The text is placed at (0, 0) with baseline+left alignment, by default. The
714 width and height of the TextArea instance is the width and height of its
715 child text.
716 """
717
718 def __init__(self, s,
719 *,
720 textprops=None,
721 multilinebaseline=False,
722 ):
723 """
724 Parameters
725 ----------
726 s : str
727 The text to be displayed.
728 textprops : dict, default: {}
729 Dictionary of keyword parameters to be passed to the `.Text`
730 instance in the TextArea.
731 multilinebaseline : bool, default: False
732 Whether the baseline for multiline text is adjusted so that it
733 is (approximately) center-aligned with single-line text.
734 """
735 if textprops is None:
736 textprops = {}
737 self._text = mtext.Text(0, 0, s, **textprops)
738 super().__init__()
739 self._children = [self._text]
740 self.offset_transform = mtransforms.Affine2D()
741 self._baseline_transform = mtransforms.Affine2D()
742 self._text.set_transform(self.offset_transform +
743 self._baseline_transform)
744 self._multilinebaseline = multilinebaseline
745
746 def set_text(self, s):
747 """Set the text of this area as a string."""
748 self._text.set_text(s)
749 self.stale = True
750
751 def get_text(self):
752 """Return the string representation of this area's text."""
753 return self._text.get_text()
754
755 def set_multilinebaseline(self, t):
756 """
757 Set multilinebaseline.
758
759 If True, the baseline for multiline text is adjusted so that it is
760 (approximately) center-aligned with single-line text. This is used
761 e.g. by the legend implementation so that single-line labels are
762 baseline-aligned, but multiline labels are "center"-aligned with them.
763 """
764 self._multilinebaseline = t
765 self.stale = True
766

Callers 10

__init__Method · 0.90
_init_legend_boxMethod · 0.90
test_pickingFunction · 0.90
test_textarea_propertiesFunction · 0.90
test_paddedboxFunction · 0.90
annotations.pyFile · 0.90
draw_textFunction · 0.90
draw_sizebarFunction · 0.90
__init__Method · 0.85

Calls

no outgoing calls

Tested by 3

test_pickingFunction · 0.72
test_textarea_propertiesFunction · 0.72
test_paddedboxFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…