Sans-serif Font for Axes Tick-labels with Latex(带有乳胶的轴刻度标签的无衬线字体)
问题描述
我第一次尝试将 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.
这篇关于带有乳胶的轴刻度标签的无衬线字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:带有乳胶的轴刻度标签的无衬线字体


- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01
- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01
- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01