Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python matplotlib increase bar label font size

I have a subplot which may include different stacked bar charts. I want to increase the font size of the bar label as it is appearing small. for ex. in

ax.bar(adjlocs, ...
 label='...', ...)

I want the font size of what is set to label to be larger. I did find ways to increase the text size of others in the plot except this one. How to achieve this? Thanks

like image 445
mj1261829 Avatar asked Jul 18 '26 16:07

mj1261829


2 Answers

Well, I got the answer. You can change the fontsize using ax.legend:

ax.legend(loc='best', fontsize=25)

Hope it helps anybody else with the same problem!

like image 108
mj1261829 Avatar answered Jul 20 '26 05:07

mj1261829


If I understood your question correctly, you are trying to change the font size not the axis or legend, but on the actual values that are written on the bars. The easiest way is to add this:

plt.rcParams['font.size'] = 6

I think the default is 12.

like image 37
Dmytro Valiaiev Avatar answered Jul 20 '26 07:07

Dmytro Valiaiev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!