问题描述
如何仅更改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)
但是对于我来说,我想使y轴标签大于x轴.但是,我想不打勾标签.
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.
例如,我尝试过:
pylab.gca().get_ylabel().set_fontsize(60)
但我只能得到:
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.
推荐答案
如果您使用"pylab"进行交互式绘图,则可以在创建时使用pylab.ylabel('Example', fontsize=40)
设置标签大小.
If you are using the 'pylab' for interactive plotting you can set the labelsize at creation time with pylab.ylabel('Example', fontsize=40)
.
如果您以编程方式使用pyplot
,则可以在创建时使用ax.set_ylabel('Example', fontsize=40)
设置字体大小,也可以在之后使用ax.yaxis.label.set_size(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标签大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!