I know there are already several questions about this (e.g. Sans-serif math with latex in matplotlib) , but I keep having problems with setting the latex font from within matplotlib. I am using
font = {'family' : 'serif',
'serif': 'helvet',
'weight' : 'bold',
'size' : 20}
matplotlib.rc('font', **font)
matplotlib.rc('text', usetex=True)
This looks right on the first glance, but when one looks more closely it seems that the width of the letters in the figure does not match the width of the letters in a manuscript compiled with latex (see screenshot).
Note that this question is about the text in the figures, not about the math-font in them (which works perfectly), and that it is also not simply an issue about the font size. So I have two questions:
Does the serif-setting in the font do anything for my parameters (I have also used Computer Modern Roman, but couldn't tell the difference).
Is there a way to get this font exactly right?
I know this might look like I'm a stickler, but I use matplotlib for my work where I do need to match these fonts precisely. If this is impossible, I'll need to use an external graphics (or latex/psfrag) software to insert the font after producing the figure - which is okay, but I'd be grateful to know what people have thought about this or handle these issues before I stop trying. Thanks!