问题描述
我第一次尝试将 Latex 与 matplotlib 一起使用.似乎在使用 Latex matplotlib 时,轴标签使用了衬线字体.我尝试使用
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 font-family to 'sans-serif' using
rc('font',family='sans-serif')
但这没有效果,我假设这是因为轴标签位于数学环境中.有没有办法设置rc",以便 matplotlib 为轴标签使用无衬线字体?
but this had no effect, I'm assuming this is because the axes-labels are inside a math-environment. Is there a way to set the 'rc' so that matplotlib will use a sans-serif font for the axes labels?
谢谢!
推荐答案
在 sfmath 包.要在 matplotlib 中使用这个包,您需要更改它用于编译文本的 LaTeX 前导码,这可以通过 'text.latex.preamble' rc 选项来完成.因此,
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}')
应该做你想做的.您还可以选择另一种字体并将其作为选项提供给包,请参阅 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.
这篇关于带有乳胶的轴刻度标签的无衬线字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!


大气响应式网络建站服务公司织梦模板
高端大气html5设计公司网站源码
织梦dede网页模板下载素材销售下载站平台(带会员中心带筛选)
财税代理公司注册代理记账网站织梦模板(带手机端)
成人高考自考在职研究生教育机构网站源码(带手机端)
高端HTML5响应式企业集团通用类网站织梦模板(自适应手机端)