我試圖用matplotlib生成一個圖並使用'stix'字體(rcParams ['mathtext.fontset'] ='stix')以便具有從文本到數學文本的平滑字體大小轉換。然而,我想要的一些數學符號是斜體(標量值),有些是斜體和粗體(張量)。我不想通過使用Latex渲染的解決方案,導致其他事情混亂。如果你運行該代碼的第一個標籤是斜體和第二個標籤是大膽使用stix字體在Matplotlib中製作斜體和粗體樣式的標籤
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()
:
我會給你描繪了問題的一個小例子。我怎樣才能實現第二個標籤是粗體和斜體?
Problem with math text to be Italic and bold
我不認爲這是可能的。你可能需要使用真正的乳膠(即usetex = True),然後這個問題可能會有所幫助:https://tex.stackexchange.com/questions/14395/bold-italic-vectors – ImportanceOfBeingErnest