我创建了一个条形图,每个条形图中都有一些文字,现在,我想知道如果可以修改这个文本的大小,字体大小,以便减少它。
我已经像这样生成了它:
#some stuff
...
...
rects1 = plt.bar(test, y, bar_width, alpha=opacity, color='b')
labels = []
for bar in rects1:
height = bar.get_height()
ax.text(bar.get_x()+bar.get_width()/4., 0.65*height, '%.2f'%float(height), rotation='vertical', horizontalalignment='left', va='bottom')
labels.append(bar.get_x()+bar.get_width()/2.)
...
...
...
结果看起来或多或少是这样的:
答案 0 :(得分:1)
您可能正在寻找:http://matplotlib.org/users/text_props.html
例如,您可以添加
ax.text(bar.get_x()+bar.get_width()/4., 0.65*height, '%.2f'%float(height), rotation='vertical', horizontalalignment='left', va='bottom', weight='bold')
使用粗体字体。您可以使用fontsize = somenumber来更改字体大小。