简体   繁体   English

我可以将 label 的 x 轴设为 \rho,即 matplotlib 中的希腊字母吗?

[英]Can I label the x-axis as \rho, the Greek letter in matplotlib?

I have used \alpha, \lambda etc to label axes in matplotlib, but it seems that \rho is not allowed.我在 matplotlib 中使用了 \alpha、\lambda etc 到 label 轴,但似乎不允许 \rho。 Is it because not every Greek letter is allowed?是不是因为不是每个希腊字母都被允许? Can I label the x-axis as \rho?我可以将 X 轴 label 作为 \rho 吗?

import matplotlib.pyplot as plt
from np.random import normal

plt.figure()
plt.plot(np.linspace(0,10,100), normal(0,1,100), color="darkblue")
plt.xlabel("$\rho$")
plt.ylabel("Values")
plt.show()

You can do it and you must have been really close if you got alpha and lambda to display.你可以做到,如果你有 alpha 和 lambda 要显示,你一定非常接近。

What you missed is the r in front of it.你错过的是它前面的r。 It should look like this:它应该如下所示:

plt.xlabel(r"$\rho$")

Here is the documentation 这是文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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