Subscripts in matplotlib axes

后端 未结 1 1759
清酒与你
清酒与你 2021-01-26 07:47

I am trying to write some variable alpha with a subscript \"mod\" while putting text on one of my plots in matplotlib. I know how to do one-letter or one-number subscripts via d

相关标签:
1条回答
  • 2021-01-26 08:16

    Short answer: Use curly brackets $\alpha_{mod}$

    Longer version: Matplotlib uses LaTeX format for strings. In LaTeX, if you want a subscript to include more than one letter you have to use curly brackets.

    import matplotlib.pyplot as plt
    ax = plt.gca()
    ax.text(2, 2, r'$\alpha_{mod}$', fontsize=10)
    y = [2,3,4,5]
    x = [1,2,3,4]
    plt.plot(x,y)
    plt.show()
    
    0 讨论(0)
提交回复
热议问题