没有TeX,有没有办法在Matplotlib中做下标/上标?

Arn*_*old 5 python matplotlib

我发现TeX弄乱了我的字体,子图yaxis标签的对齐方式等,我觉得必须有一种更简单的方法来获取图例标签中的子脚本和上标。救命!

Joe*_*ton 5

只需\mathregular{whatever}在您的表情中使用即可。

例如:

import matplotlib.pyplot as plt
fig, ax = plt.subplots()
ax.text(0.2, 0.7, 'No mathtex')
ax.text(0.2, 0.5, 'This superscript $is^{in}$ italics')
ax.text(0.2, 0.3, 'While this $\mathregular{is^{really}}$ the same font')
plt.show()
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

有关更多信息,请参见http://matplotlib.org/users/mathtext.html