Writing Mathematical Expressions
In case you need to write mathematical expressions within the code, Matplotlib supports TeX, one of the most popular typesetting systems, especially for typesetting mathematical formulas. You can use it in any text by placing your mathematical expression in a pair of dollar signs. There is no need to have TeX installed since Matplotlib comes with its own parser.
An example of this is given in the following code:
plt.xlabel(‚$x$') plt.ylabel(‚$\cos(x)$')
The following diagram shows the output of the preceding code:
TeX examples:
'$\alpha_i>\beta_i$'
produces .'$\sum_{i=0}^\infty x_i$'
produces'$\sqrt[3]{8}$'
produces .'$\frac{3 - \frac{x}{2}}{5}$'
produces
In this section, we learned how to write a basic mathematical expression and generate a plot using it...