2017-04-06 132 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