Subscripting Text In Matplotlib Labels
this is my first question and I am a noob at python. So probably more to follow... I would like to create a figure with matplotlib. In the labels, I would like to include a chemica
Solution 1:
Try to change this line
plt.plot(x,y, label='H2O')
for this:
plt.plot(x,y, label='$H_2O$')
It shows with the font math.
Or also you can use the unicode character for that: ₂ (0xE2 / ₂)
plt.plot(x,y, label=u'H₂O')
or instead:
plt.plot(x,y, label=u"H\u2082O")
Please, note that unicode strings are noted as u"" instead than "".
Post a Comment for "Subscripting Text In Matplotlib Labels"