Sans-serif Font for Axes Tick-labels with Latex

后端 未结 1 1701
庸人自扰
庸人自扰 2021-01-20 02:19

I\'m trying to use Latex with matplotlib for the first time. It seems that when using Latex matplotlib uses a serif font for the axes labels. I tried explicitly setting the

1条回答
  •  北荒
    北荒 (楼主)
    2021-01-20 02:46

    Sans-serif math fonts can be used in LaTeX with the help of the sfmath package. To use this package in matplotlib, you need to alter the LaTeX preamble it uses to compile text, which can be done through the 'text.latex.preamble' rc option. Hence,

    rc('text.latex', preamble='\usepackage{sfmath}')
    

    should do what you want. You can also choose another font and supply it as an option to the package, see sfmath's documentation for reference.

    0 讨论(0)
提交回复
热议问题