文本和图例框中的图标对齐(matplotlib)

时间:2015-08-23 14:16:14

标签: python matplotlib

我想减少我的情节图例中文字的大小,以便tikz数字可以保持相对较大。问题是当我减少图例中字体的大小时,图例中的图标与文本之间的对齐方式会受到影响。我怎样才能再次配对? 以下是测试:

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)
plt.setp(legend.get_texts(), fontsize='15') #legend 'list' fontsize
fig.set_size_inches(14.5, 10.5)
plt.savefig('/Users/Cupitor/Test.png')

正如您可以在下面的图片中看到的那样,图例中的文字对于左侧的绿色图形来说并不是更加重要: enter image description here

0 个答案:

没有答案