Multiple fontsize in same label Matplotlib

后端 未结 2 1341
忘掉有多难
忘掉有多难 2021-01-12 04:08

I\'m trying to do something relatively simple:

I want to be able to increase a font of one letter(say a LaTeX variable, say to 30) and keep the other letters in the

2条回答
  •  无人共我
    2021-01-12 04:56

    Here is the solution with LaTeX. The machine I have doesn't have LaTeX installed, so I haven't tested this carefully.

    plt.plot(a,b,'g',linewidth=3.5, label = 'a')
    plt.rc('text', usetex=True)
    plt.legend(labelspacing = 1.0,loc=1,prop={'size':40})
    plt.xlabel(r'{\fontsize{50pt}{3em}\selectfont{}a}{\fontsize{20pt}{3em}\selectfont{}N')
    

    (note the r before the string. This tells pylab to just send the string directly to LaTeX as a raw string rather than treating \f and \s as special characters)

    You can get much more elaborate with the size commands of LaTeX (you can specify the actual font, or use various versions of the \large, \Large, \small \tiny ... commands).

提交回复
热议问题