Michael Dorner
Michael Dorner

Reputation: 20185

PGF output from matplotlib not adjusted to the LaTeX template

My goal is to use the font and its size from the template (in my particular case the ieeetran.cls) for my plots.

With Python/Jupyter and matplotlib I create a plot which I store as pgf file, which works fine:

plt.rcParams.update({
    'font.family': 'sans-serif', # used for the plot in Jupyter
    'text.usetex': True, # used for the plot in Jupyter
    'pgf.rcfonts': False, # actually I thought this is the essential line
})
fig, ax = plt.subplots(figsize=(7.16, 3), dpi=300)
# do the plot
plt.savefig('../reports/plot.pgf')

But in the latex file, using

\input{figures/plot.pgf}

the fonts in the plot (especially the size) is not set correctly:

enter image description here

Please notice the different sizes for the caption and the legend or numbers.

I thought setting up 'pgf.rcfonts': False does the trick... What am I doing wrong?

Upvotes: 0

Views: 429

Answers (0)

Related Questions