python - How to modify the text in a bar chart -
I have created a chart once, with some text within each bar, now, if I could
I have created it like this:
# Some stuff ... ... modify the size of this text, font size, to reduce it a little bit. rects1 = plt.bar (test, y, bar_width, alpha = opacity, color = 'b') label = [] in rects1 for bar: height = bar.get_height () ax.text (bar.get_x) + bar get_width () / 4, 0.65 * height, '% .2f'% float (height), rotation = 'vertical', horizontal alignment = 'left', va = 'bottom') label.endend (bar.get_x) + bar.get_width () / 2.) ... ... ... More results look more or less like this:
You may be looking for:
For example you
ax.text (bar.get_x) + bar.get_widt h (vertical), horizontal alignment = 'left', va = 'bottom', weight = 'bold' ) To use a bold font, you can use fontsize = somenumber to change the font size.
Comments
Post a Comment