2017-04-06 128 views
0

我在使用tex表達式到matplotlib並將它們置於粗體格式方面存在問題。我目前無法找到解決方案。在matplotlib中使用數學表達式的粗體格式

這是一個簡單的例子。我怎樣才能把下標,上標和希臘字母變成粗體?


import matplotlib.pyplot as plt 
import numpy as np 
from matplotlib import rc 

rc('text', usetex=True) 

x = np.arange(10) 

first_plot, = plt.plot(x[:],2*x[:],'k-') 

second_plot, = plt.plot(x[:],4*x[:],'k-') 

third_plot, = plt.plot(x[:],6*x[:],'k-') 

plt.legend([first_plot,second_plot,third_plot],[r'\textbf{A}$_\sigma$', 
r'\textbf{B}',r'\textbf{a$^2$}'], fontsize=36, loc=[0.4,0.70],frameon=False) 

plt.show() 

回答

0

這是相當關係到乳膠比matplotlib。但對於這種簡單的情況,您可以使用\boldmath

[ r'\textbf{A}\boldmath$_\sigma$', 
    r'\textbf{B}', 
    r'\textbf{a\boldmath$^2$}'] 

enter image description here

參見例如在tex.stackexchange上的this question

+0

感謝,似乎解決我的問題! – Thomas