我正在尝试使用 matplotlib 生成一个绘图,并使用 'stix' 字体 (rcParams['mathtext.fontset'] = 'stix') 以使字体大小从文本平滑过渡到数学文本。然而,我的一些数学符号我想是斜体(标量值),有些是斜体和粗体(张量)。我不想通过使用 Latex 渲染的解决方案,然后其他事情就搞砸了。
我会给你一个描述问题的小例子:
from numpy import *
from matplotlib.pyplot import *
# Chaning font to stix
rcParams['mathtext.fontset'] = 'stix'
# Some data to constract this plotting example
datax=[0,1,2]
datay=[8,9,10]
datay2=[8,15,10]
fig, ay = subplots()
ay.plot(datax, datay, color="0.", ls='-', label= r"$F_{\alpha}$")
ay.plot(datax, datay2, color="0.", ls='-', label=r"$\mathbf{F_{\alpha}}$")
# Now add the legend with some customizations.
legend = ay.legend(loc='left', shadow=True)
#frame = legend.get_frame()
#frame.set_facecolor('0.90')
xlabel(r"x label",fontsize=18)
ylabel(r'y label', fontsize=18)
grid()
show()
Run Code Online (Sandbox Code Playgroud)
如果您运行代码,第一个标签是斜体,第二个标签是粗体。我怎样才能使第二个标签成为粗体和斜体? …
matplotlib ×1