开发者

How do I write text in subscript in the axis labels and the legend?

开发者 https://www.devze.com 2023-01-20 22:59 出处:网络
I have the following axis labels and legend. plt.ylabel(\"ratio_2\") plt.xlabel(\"n_1\") plt.legend((\'alpha_1\',\'alpha_2\' ), loc = \'开发者_运维知识库best\',shadow = True)

I have the following axis labels and legend.

plt.ylabel("ratio_2")
plt.xlabel("n_1")
plt.legend(('alpha_1','alpha_2' ), loc = '开发者_运维知识库best',shadow = True)   


Put dollar signs around the formula: plt.xlabel("$n_1$")


The easiest way I know is to enable TeX mode for matplotlib,

from http://www.scipy.org/Cookbook/Matplotlib/UsingTex:

from matplotlib import rc
rc('font',**{'family':'sans-serif','sans-serif':['Helvetica']})
rc('text', usetex=True)
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号