简体   繁体   English

python matplotlib 增加栏 label 字体大小

[英]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.我想增加栏 label 的字体大小,因为它看起来很小。 for ex.例如。 in

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

I want the font size of what is set to label to be larger.我希望设置为 label 的字体大小更大。 I did find ways to increase the text size of others in the plot except this one.我确实在 plot 中找到了增加其他字体大小的方法,除了这个。 How to achieve this?如何做到这一点? Thanks谢谢

Well, I got the answer. 好吧,我得到了答案。 You can change the fontsize using ax.legend: 您可以使用ax.legend更改字体大小:

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

Hope it helps anybody else with the same problem! 希望它可以帮助其他有相同问题的人!

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.我认为默认值是 12。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM