Reputation: 5739
I have created a bar chart, with some text inside each bar, now, I would like to knkow if it is possible to modify the size of this text, the font size, in order to reduce it a bit.
I have generated it like this:
#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.)
...
...
...
And the result looks more or less like this:
Upvotes: 0
Views: 972
Reputation: 2445
You are probably looking for this: http://matplotlib.org/users/text_props.html
For instance you can add
ax.text(bar.get_x()+bar.get_width()/4., 0.65*height, '%.2f'%float(height), rotation='vertical', horizontalalignment='left', va='bottom', weight='bold')
To use a bold font. You can use fontsize=somenumber to change the font size.
Upvotes: 1