|
1 | 1 | r""" |
2 | 2 | Writing mathematical expressions |
3 | 3 | ================================ |
4 | | -
|
5 | 4 | An introduction to writing mathematical expressions in Matplotlib. |
6 | 5 |
|
7 | 6 | You can use a subset TeX markup in any matplotlib text string by placing it |
|
56 | 55 |
|
57 | 56 | Subscripts and superscripts |
58 | 57 | --------------------------- |
59 | | -
|
60 | 58 | To make subscripts and superscripts, use the ``'_'`` and ``'^'`` symbols:: |
61 | 59 |
|
62 | 60 | r'$\alpha_i > \beta_i$' |
|
86 | 84 |
|
87 | 85 | Fractions, binomials, and stacked numbers |
88 | 86 | ----------------------------------------- |
89 | | -
|
90 | 87 | Fractions, binomials, and stacked numbers can be created with the |
91 | 88 | ``\frac{}{}``, ``\binom{}{}`` and ``\genfrac{}{}{}{}{}{}`` commands, |
92 | 89 | respectively:: |
|
130 | 127 |
|
131 | 128 | Radicals |
132 | 129 | -------- |
133 | | -
|
134 | 130 | Radicals can be produced with the ``\sqrt[]{}`` command. For example:: |
135 | 131 |
|
136 | 132 | r'$\sqrt{2}$' |
|
153 | 149 |
|
154 | 150 | Fonts |
155 | 151 | ----- |
156 | | -
|
157 | 152 | The default font is *italics* for mathematical symbols. |
158 | 153 |
|
159 | 154 | .. note:: |
|
270 | 265 |
|
271 | 266 | Custom fonts |
272 | 267 | ~~~~~~~~~~~~ |
273 | | -
|
274 | 268 | mathtext also provides a way to use custom fonts for math. This method is |
275 | 269 | fairly tricky to use, and should be considered an experimental feature for |
276 | 270 | patient users only. By setting :rc:`mathtext.fontset` to ``custom``, |
|
306 | 300 |
|
307 | 301 | Accents |
308 | 302 | ------- |
309 | | -
|
310 | 303 | An accent command may precede any symbol to add an accent above it. There are |
311 | 304 | long and short forms for some of them. |
312 | 305 |
|
|
346 | 339 |
|
347 | 340 | Symbols |
348 | 341 | ------- |
349 | | -
|
350 | 342 | You can also use a large number of the TeX symbols, as in ``\infty``, |
351 | 343 | ``\leftarrow``, ``\sum``, ``\int``. |
352 | 344 |
|
|
359 | 351 |
|
360 | 352 | Example |
361 | 353 | ------- |
362 | | -
|
363 | 354 | Here is an example illustrating many of these features in context. |
364 | 355 |
|
365 | 356 | .. figure:: ../../gallery/pyplots/images/sphx_glr_pyplot_mathtext_001.png |
|
0 commit comments