Open
Description
Apparently, matplotlib uses different rcParams for controlling the font used in LaTeX environments vs outside (see https://stackoverflow.com/a/27697390). This causes behaviour which is IMO inconsistent, where the font family specified in the theme
is not used within LaTeX environments.
Reproducible example to show what I mean:
from plotnine import ggplot, geom_point, aes, theme, labs, element_text
from plotnine.data import penguins
(ggplot(penguins, aes(x="bill_length_mm", y="bill_depth_mm"))
+ labs(x="l_bill", y=r"$d_\text{bill}$")
+ theme(text = element_text(family="Noto Serif"), figure_size=(3,2))
+ geom_point()
)
yields this:
where the LaTeX in the y axis label does not use the serif font which I specified in the theme
Prepending this:
import matplotlib
matplotlib.rcParams['mathtext.fontset'] = 'custom'
matplotlib.rcParams['mathtext.rm'] = 'Noto Serif'
matplotlib.rcParams['mathtext.it'] = 'Noto Serif:italic'
achieves the desired result in this case, but of course, the theme information is no longer stored in the theme.
Is it possible to change the behaviour such that the LaTeX font follows the theme font?
Metadata
Metadata
Assignees
Labels
No labels