python - 在绘图中键入希腊字母等

标签 python matplotlib

我需要在绘图的轴标签中输入希腊字母和埃符号。比如

fig.gca().set_xlabel("$wavelength\, (Angstrom)$")
fig.gca().set_ylabel("$lambda$")

除了我实际上想用实际符号替换“Angstrom”和“lambda”。我该怎么做?谢谢!

最佳答案

您需要制作字符串 raw并使用 latex :

fig.gca().set_ylabel(r'$\lambda$')

从 matplotlib 2.0 开始,默认字体 supports most western alphabets并且可以简单地做

ax.set_xlabel('λ')

使用 unicode。

关于python - 在绘图中键入希腊字母等,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13338550/

相关文章:

python - 递归命名正则表达式组

Python 引用计数

python - 通过索引创建有序矩阵

python-3.x - Python pyplot : Handling double-click event catches also the first click event

python - Python FFT 中的 DC 项 - 常数项的幅度

python - 使用 python 3.3 在 Django 1.9 中导入 WeakMethod 错误

python - emacs python 代码补全

python - 在 python 中交互式地旋转 3D 图 - matplotlib - Jupyter Notebook

python - 将一条线拟合到python中的矩阵

python - 如何删除matplotlib图像的框架并将背景颜色设置为透明