如何在matplotlib的图例中设置缩略图/图标的大小?一种方法是操纵图例中的文本大小,以便使用plt.setp(fig.gca().get_legend().get_texts(), fontsize='15')
使图标看起来相对较大/较小。
有没有直接的方法来更改代表图例中情节的缩略图/图标的大小?
import numpy as np
from matplotlib import pyplot as plt
plt.rc('text', usetex = True)
font = {'family' : 'normal',
'weight' : 'normal',
'size' : 25}
plt.rc('font', **font)
fig, ax = plt.subplots(1, 1)
a = np.arange(10)
b = np.random.randn(10)
ax.errorbar(a, b, yerr=0.5, fmt='o', color='g', ecolor='g', capthick=1, linestyle = '-', linewidth=2, elinewidth=1, label = "Test")
legend = plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=2, ncol=6, mode="expand", borderaxespad=0.2)
fig.set_size_inches(14.5, 10.5)
plt.savefig('/Users/Cupitor/Test.png')