Phys251 Phys251 - 6 months ago 23
Python Question

Does Matplotlib have an incomplete set of Greek characters in its LaTeX?

Lines such as the following will work fine with matplotlib:

plt.xlabel('$\gamma$')
plt.xlabel('$\Gamma$')
plt.xlabel('$\pi$')
plt.xlabel('$\Pi$')


And they give the nice, LaTeX font on the graph.

But if I try to run any of these:

plt.xlabel('$\beta$')
plt.xlabel('$\Beta$')
plt.xlabel('$\alpha$')
plt.xlabel('$\Alpha$')


I get the following error:

ValueError:
\Beta
^
Unknown symbol: \Beta (at char 0), (line:1, col:1)


This makes no sense. I need to use beta in this plot, and I do not want to have to resort to just calling it "beta." How do I get this to work?

Answer

Ed Smith's answer (see comment above) did it. I just had to use this line:

plt.xlabel(r'$\beta$')
Comments