Phys251 - 1 year ago 118
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 Source

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

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download