Python 有没有一种方法可以在Matplotlib中不使用TeX进行下标/上标操作?

Python 有没有一种方法可以在Matplotlib中不使用TeX进行下标/上标操作?,python,matplotlib,Python,Matplotlib,我发现TeX会弄乱我的字体,我的子绘图yaxis标签的对齐方式,等等,我觉得必须有一种更简单的方法来获取绘图标签中的子字符和上标。救命啊 只需在表达式中使用\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')

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

只需在表达式中使用
\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()


有关更多信息,请参阅。

我不知道有什么方法可以在不使用mathtext引擎的情况下使用类似TeX的渲染(或直接使用LaTeX)。但是,如果您的问题确实与文本对齐有关,那么文本对齐kwargs
水平对齐
垂直对齐
多重对齐
可能会有所帮助

此处的文档: