|
| 1 | +.. _text-guide: |
| 2 | + |
| 3 | +Working with text |
| 4 | +################# |
| 5 | + |
| 6 | +.. toctree:: |
| 7 | + |
| 8 | + text_props.rst |
| 9 | + mathtext.rst |
| 10 | + usetex.rst |
| 11 | + annotations.rst |
| 12 | + |
| 13 | + |
| 14 | +matplotlib has excellent text support, including mathematical |
| 15 | +expressions, truetype support for raster and vector outputs, newline |
| 16 | +separated text with arbitrary rotations, and unicode support. Because |
| 17 | +we embed the fonts directly in the output documents, eg for postscript |
| 18 | +or PDF, what you see on the screen is what you get in the hardcopy. |
| 19 | +`freetype2 <http://freetype.sourceforge.net/index2.html>`_ support |
| 20 | +produces very nice, antialiased fonts, that look good even at small |
| 21 | +raster sizes. matplotlib includes its own |
| 22 | +:mod:`matplotlib.font_manager`, thanks to Paul Barrett, which |
| 23 | +implements a cross platform, W3C compliant font finding algorithm. |
| 24 | + |
| 25 | +You have total control over every text property (font size, font |
| 26 | +weight, text location and color, etc) with sensible defaults set in |
| 27 | +the rc file. And significantly for those interested in mathematical |
| 28 | +or scientific figures, matplotlib implements a large number of TeX |
| 29 | +math symbols and commands, to support mathematical expressions |
| 30 | +anywhere in your figure. |
| 31 | + |
| 32 | + |
| 33 | +Basic text commands |
| 34 | +=================== |
| 35 | + |
| 36 | +The following commands are used to create text in the pyplot |
| 37 | +interface |
| 38 | + |
| 39 | +* :func:`~matplotlib.pyplot.text` - add text at an arbitrary location to the ``Axes``; |
| 40 | + :meth:`matplotlib.axes.Axes.text` in the API. |
| 41 | + |
| 42 | +* :func:`~matplotlib.pyplot.xlabel` - add an axis label to the x-axis; |
| 43 | + :meth:`matplotlib.axes.Axes.set_xlabel` in the API. |
| 44 | + |
| 45 | +* :func:`~matplotlib.pyplot.ylabel` - add an axis label to the y-axis;; |
| 46 | + :meth:`matplotlib.axes.Axes.set_ylabel` in the API. |
| 47 | + |
| 48 | +* :func:`~matplotlib.pyplot.title` - add a title to the ``Axes``; |
| 49 | + :meth:`matplotlib.axes.Axes.set_title` in the API. |
| 50 | + |
| 51 | +* :func:`~matplotlib.pyplot.figtext` - add text at an arbitrary location to the ``Figure``; |
| 52 | + :meth:`matplotlib.figure.Figure.text` in the API. |
| 53 | + |
| 54 | +* :func:`~matplotlib.pyplot.suptitle` - add a title to the ``Figure``; |
| 55 | + :meth:`matplotlib.figure.Figure.suptitle` in the API. |
| 56 | + |
| 57 | +* :func:`~matplotlib.pyplot.annotate` - add an annotation, with |
| 58 | + optional arrow, to the ``Axes`` ; :meth:`matplotlib.axes.Axes.annotate` |
| 59 | + in the API. |
| 60 | + |
| 61 | +All of these functions create and return a |
| 62 | +:func:`matplotlib.text.Text` instance, which can bew configured with a |
| 63 | +variety of font and other properties. |
0 commit comments