Hello!
I search the whole time but cannot find it. How to show an easy latex-formula in python? Maybe numpy is the right choice?
EDIT:
I have a python code like:
a = '\frac{a}{b}'
and want to print this in a graphical output (like matplotlib).
Hello!
I search the whole time but cannot find it. How to show an easy latex-formula in python? Maybe numpy is the right choice?
EDIT:
I have a python code like:
a = '\frac{a}{b}'
and want to print this in a graphical output (like matplotlib).
Matplotlib can already do TeX, by setting text.usetex: True in ~/.matplotlib/matplotlibrc. Then, you can just use TeX in all displayed strings, e.g.,
ylabel(r"Temperature (K) [fixed $\beta=2$]")
(be sure to use the $ as in normal in-line TeX!). The r before the string means that no substitutions are made; otherwise you have to escape the slashes as mentioned.
More info at the matplotlib site.
As suggested by Andrew little work around using matplotlib.
import matplotlib.pyplot as plt
a = '\\frac{a}{b}' #notice escaped slash
plt.plot;plt.text(0.5,0.5,'$%s$'%a)