简体   繁体   中英

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?

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM