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

前端 未结 2 955
予麋鹿
予麋鹿 2020-12-16 11:02

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)         


        
2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-16 11:26

    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)
    

提交回复
热议问题