{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\nWriting mathematical expressions\n================================\n\nAn introduction to writing mathematical expressions in Matplotlib.\n\nYou can use a subset TeX markup in any matplotlib text string by\nplacing it inside a pair of dollar signs ($).\n\nNote that you do not need to have TeX installed, since matplotlib\nships its own TeX expression parser, layout engine and fonts. The\nlayout engine is a fairly direct adaptation of the layout algorithms\nin Donald Knuth's TeX, so the quality is quite good (matplotlib also\nprovides a ``usetex`` option for those who do want to call out to TeX\nto generate their text (see `sphx_glr_tutorials_text_usetex.py`).\n\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Any text element can use math text. You should use raw strings (precede the\nquotes with an ``'r'``), and surround the math text with dollar signs ($), as in\nTeX. Regular text and mathtext can be interleaved within the same string.\nMathtext can use DejaVu Sans (default), DejaVu Serif, the Computer Modern fonts\n(from (La)TeX), `STIX
On `\"narrow\"
Mathtext should be placed between a pair of dollar signs ($). To\n make it easy to display monetary values, e.g., \"$100.00\", if a\n single dollar sign is present in the entire string, it will be\n displayed verbatim as a dollar sign. This is a small change from\n regular TeX, where the dollar sign in non-math text would have to\n be escaped ('\\\\\\$').
While the syntax inside the pair of dollar signs ($) aims to be\n TeX-like, the text outside does not. In particular, characters\n such as::\n\n # $ % & ~ _ ^ \\ { } \\( \\) \\[ \\]\n\n have special meaning outside of math mode in TeX. Therefore, these\n characters will behave differently depending on the rcParam\n ``text.usetex`` flag. See the `usetex tutorial\n
This default can be changed using the ``mathtext.default`` rcParam.\n This is useful, for example, to use the same font as regular\n non-math text for math text, by setting it to ``regular``.