How do I make sans serif superscript or subscript text in matplotlib?(如何在 matplotlib 中制作无衬线上标或下标文本?)
问题描述
我想在 matplotlib 图中的轴标签中使用下标.使用 LaTeX,我会将其设置为 $N_i$,这给了我斜体衬线字体.我知道我可以使用 mathrm 获得非斜体数学字体.但我想获取默认 matplotlib sans-serif 字体中的文本,以便它与图中的其余文本匹配.有没有不使用乳胶的下标文本的方法?
I want to use a subscript in an axis label in a matplotlib figure. Using LaTeX I would set it as $N_i$, which gives me the italic serif font. I know I can get non-italic mathfont with mathrm. But I would like to get the text in the default matplotlib sans-serif font so it matches the rest of the text in the figure. Is there a way to subscript text without using latex?
推荐答案
使用 mathregular 在 mathtext 之外使用用于常规文本的字体:
Use mathregular to use the font used for regular text outside of mathtext:
$mathregular{N_i}$
查看此处了解更多信息.
这篇关于如何在 matplotlib 中制作无衬线上标或下标文本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 matplotlib 中制作无衬线上标或下标文本?
基础教程推荐
- 由Python将MP3转换为MIDI(类型错误:无法加载插件:mtg-Melodia:Melodia) 2022-01-01
- pyserial - 可以从线程 a 写入串行端口,是否阻塞从线程 b 读取? 2022-01-01
- numpy float:比算术运算中内置的慢 10 倍? 2022-01-01
- 将 x 轴刻度更改为自定义字符串 2022-01-01
- Discord.py 缺少必需的参数 2022-01-01
- 使用生成器和迭代器时 Python 多循环失败 2022-01-01
- 用 Python 编写 Fortran 无格式文件 2022-01-01
- 与常规 dict 相比,Python manager.dict() 非常慢 2022-01-01
- 在 Celery 工作人员中捕获 Heroku SIGTERM 以优雅地关 2022-01-01
- 尝试制作WhatsApp机器人 2022-01-01
