我创建了一个条形图,现在每个条形图内都有一些文本,如果可以修改此文本的大小(字体大小)以使其减少一点,我想表示感谢。
我已经生成了这样的:
#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.)
...
...
...
结果看起来或多或少是这样的:
您可能正在寻找: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更改字体大小。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句