Mathematics and Greek symbols


matplotlib can display mathematical formulas, Greek letters, and mathematical symbols using a math rendering module known as mathtext. The mathtext module parses a subset of Donald Knuth’s TEX mathematical typesetting language, and provides basic mathematical typesetting without any software other than matplotlib. If, in addition, you have TEX (and/or LATEX) as a separate standalone program (such as MacTex [TexShop] or MiKTeX), then you can do even more. In what follows we will assume that you are using the native matplotlib mathtext, but will make a few comments applicable to those who have a separate installation of LATEX.

matplotlib’s mathtext can display Greek letters and mathematical symbols using the syntax of TEX. If you are familiar with TEX or LATEX, you have hardly anything to learn. Even if you are not familiar with them, the syntax is simple enough that you can employ it in most cases without too much effort.You designate text as mathtext by placing dollar signs (dollar) in a text string at the beginning and end of any part of the string that you want to be rendered as math text. You should also use raw strings in most cases, which means you should precede the quotes of a string with the letter r. For example, the following commands produces a plot with the title $\pi> 3$.

plt.plot([1, 2, 3, 2, 3, 4, 3, 4, 5])
plt.title(r'$\pi > 3$')
plt.show()



Comments

Popular posts from this blog

Python For Engineers CST 445 KTU Open Elective Notes S7 - Dr Binu V P 9847390760

Model Question Paper CST 445 KTU Python For Engineers

Plotting- Simple plots,setting limits,subplot, semilog, loglog plots