Font size discrepancies of LaTeX subscripts in matplotlib

Viewed 21

I noticed the following issue when plotting axis labels and text in matplotlib with tex enabled, specifically when the font size is set to small integer values. See the code below.

import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rc('text', usetex=True)

f,ax = plt.subplots(dpi=200)
ax.set_axis_off()

for i in range(3,8):
    ax.text(0.15,0.05*i,r'fontsize=%d$\pm0.1:$'%i,fontsize=i)
    ax.text(0.35,0.05*i,r'$E_E$',fontsize=i-0.01)
    ax.text(0.4,0.05*i,r'$E_E$',fontsize=i)
    ax.text(0.45,0.05*i,r'$E_E$',fontsize=i+0.01)
ax.set_ylim([0,0.5])
    
plt.show()

This produces:

the resulting plot

Notice that when the font size is 5, the subscript is more or less the same size as the normal text. More subtle issues also persist for font sizes of 6 and 7. Adding ±0.01 fixes it, but it's still kinda weird and annoying. Does anybody know what's going on here or how it might be fixed?

0 Answers
Related