我可以将 x 轴标记为 \rho,matplotlib 中的希腊字母吗?

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

我在matplotlib中用过\alpha, \lambda e.t.c来标注坐标轴,但是好像不允许用\rho。是因为不是每个希腊字母都被允许吗?我可以将 x 轴标记为 \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()

你可以做到,如果你要显示 alpha 和 lambda,你一定已经非常接近了。

你漏掉的是前面的r。它应该是这样的:

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

Here is the documentation