Reputation: 184
I'm currently preparing figures with matplotlib and I have set the font to Tex Gyre Pagella by modifying my .mplstyle file. Everything is now rendered using the font, but the symbols in equations do not appear italicized.
I added the following lines to my .mplstyle file:
font.family: TeX Gyre Pagella
mathtext.fontset: custom
mathtext.rm: TeX Gyre Pagella Math
mathtext.it: TeX Gyre Pagella Math
mathtext.bf: TeX Gyre Pagella Math
If I now do something like
plt.plot([1, 2, 3], [1, 4, 9])
plt.xlabel(r"$\omega$")
then the x label is correctly in the font that was specified, but not italicized. As though the symbols in TeX Gyre Pagella Math were not italic.
I have previously used these fonts to generate documents with LaTeX using
\usepackage{unicode-math}
\defaultfontfeatures{Scale=MatchLowercase}
\setmainfont{texgyrepagella-regular.otf}[
BoldFont = texgyrepagella-bold.otf ,
ItalicFont = texgyrepagella-italic.otf ,
BoldItalicFont = texgyrepagella-bolditalic.otf ]
\setmathfont{texgyrepagella-math.otf}
with symbols properly slanted. Is there a way to achieve this in matplotlib (version 3.8.0) as well?
Upvotes: 0
Views: 13