matplotlib 设置 yaxis 标签大小 [英] matplotlib set yaxis label size

查看:136
本文介绍了matplotlib 设置 yaxis 标签大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

How can I change the size of only the yaxis label? Right now, I change the size of all labels using

pylab.rc('font', family='serif', size=40)

but in my case, I would like to make the y-axis label larger than the x-axis. However, I'd like to leave the tick labels alone.

I've tried, for example:

pylab.gca().get_ylabel().set_fontsize(60)

but I only get:

AttributeError: 'str' object has no attribute 'set_fontsize'

So, obviously that doesn't work. I've seen lots of stuff for tick sizes, but nothing for the axis labels themselves.

解决方案

If you are using the 'pylab' for interactive plotting you can set the labelsize at creation time with pylab.ylabel('Example', fontsize=40).

If you use pyplot programmatically you can either set the fontsize on creation with ax.set_ylabel('Example', fontsize=40) or afterwards with ax.yaxis.label.set_size(40).

这篇关于matplotlib 设置 yaxis 标签大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆