作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有以下代码来创建如下所示的绘图:
import matplotlib.pyplot as plt
x = [...]
y = [...]
fig = plt.figure()
ax = fig.gca()
ax.set_xlabel(r'$\mathsf{Concentration [mol/m^{3}]}$')
ax.set_ylabel(r'$\mathsf{Diffusion Coefficient [m^2/s]}$')
plt.semilogy(x, y)
plt.grid(True, which="both")
plt.autoscale()
plt.savefig("coeff.pdf")
plt.show()
完全可以使用 LaTeX 数学符号作为轴标签。不幸的是,刻度线/网格线处的数字有另一种字体:
如何确保轴标签和数字具有相同的字体和样式?
最佳答案
您需要将mathtext
字体设置为常规字体:
from matplotlib import rcParams
rcParams['mathtext.default'] = 'regular'
这适用于使用 mathtext
进行方程渲染。如果你使用 Latex,你应该看看 here .
关于python - Matplotlib 中轴上的数字和轴标签具有相同的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50526864/
在引用文献中,它们被描述为: axis('equal') changes limits of x or y axis so that equal increments of x and y have
我是一名优秀的程序员,十分优秀!