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

Method text

lib/matplotlib/axes/_axes.py:653–729  ·  view source on GitHub ↗

Add text to the Axes. Add the text *s* to the Axes at location *x*, *y* in data coordinates, with a default ``horizontalalignment`` on the ``left`` and ``verticalalignment`` at the ``baseline``. See :doc:`/gallery/text_labels_and_annotations/text_alignment`.

(self, x, y, s, fontdict=None, **kwargs)

Source from the content-addressed store, hash-verified

651
652 @_docstring.interpd
653 def text(self, x, y, s, fontdict=None, **kwargs):
654 """
655 Add text to the Axes.
656
657 Add the text *s* to the Axes at location *x*, *y* in data coordinates,
658 with a default ``horizontalalignment`` on the ``left`` and
659 ``verticalalignment`` at the ``baseline``. See
660 :doc:`/gallery/text_labels_and_annotations/text_alignment`.
661
662 Parameters
663 ----------
664 x, y : float
665 The position to place the text. By default, this is in data
666 coordinates. The coordinate system can be changed using the
667 *transform* parameter.
668
669 s : str
670 The text.
671
672 fontdict : dict, default: None
673
674 .. admonition:: Discouraged
675
676 The use of *fontdict* is discouraged. Parameters should be passed as
677 individual keyword arguments or using dictionary-unpacking
678 ``text(..., **fontdict)``.
679
680 A dictionary to override the default text properties. If fontdict
681 is None, the defaults are determined by `.rcParams`.
682
683 Returns
684 -------
685 `.Text`
686 The created `.Text` instance.
687
688 Other Parameters
689 ----------------
690 **kwargs : `~matplotlib.text.Text` properties.
691 Other miscellaneous text parameters.
692
693 %(Text:kwdoc)s
694
695 Examples
696 --------
697 Individual keyword arguments can be used to override any given
698 parameter::
699
700 >>> text(x, y, s, fontsize=12)
701
702 The default transform specifies that text is in data coords,
703 alternatively, you can specify text in axis coords ((0, 0) is
704 lower-left and (1, 1) is upper-right). The example below places
705 text in the center of the Axes::
706
707 >>> text(0.5, 0.5, 'matplotlib', horizontalalignment='center',
708 ... verticalalignment='center', transform=ax.transAxes)
709
710 You can put a rectangular box around the text instance (e.g., to

Callers 15

pie_labelMethod · 0.95
test_radio_buttonsFunction · 0.45
test_check_buttonsFunction · 0.45
test_unicode_wonFunction · 0.45
test_multi_font_aspathFunction · 0.45
test_multi_font_astextFunction · 0.45
test_svg_escapeFunction · 0.45
test_svg_font_stringFunction · 0.45
test_pickFunction · 0.45
test_usetexFunction · 0.45
test_emptyFunction · 0.45

Calls 3

set_clip_pathMethod · 0.95
_add_textMethod · 0.80
get_clip_pathMethod · 0.45

Tested by 15

test_radio_buttonsFunction · 0.36
test_check_buttonsFunction · 0.36
test_unicode_wonFunction · 0.36
test_multi_font_aspathFunction · 0.36
test_multi_font_astextFunction · 0.36
test_svg_escapeFunction · 0.36
test_svg_font_stringFunction · 0.36
test_pickFunction · 0.36
test_usetexFunction · 0.36
test_emptyFunction · 0.36
test_unicode_minusFunction · 0.36