如何在tickplabel和matplotlib中的轴之间添加空间? [英] How do I add space between the ticklabels and the axes in matplotlib?
问题描述
我已经成功增加了ticklabels的字体,但是现在它们离轴太近了.我想在刻度标签和轴之间添加一点呼吸空间.
I've increased the font of my ticklabels successfully, but now they're too close to the axis. I'd like to add a little breathing room between the ticklabels and the axis.
推荐答案
看起来matplotlib将这些设置视为rcParams:
It looks like matplotlib respects these settings as rcParams:
pylab.rcParams['xtick.major.pad']='8'
pylab.rcParams['ytick.major.pad']='8'
在您创建任何图形之前,在之前设置这些,就可以了.
Set those before you create any figures and you should be fine.
我看过源代码,似乎没有其他方法可以通过编程方式设置它们. (tick.set_pad()看起来像是试图做正确的事,但是似乎在构建Ticks时设置了填充,此后便无法更改.)
I've looked at the source code and there doesn't appear to be any other way to set them programmatically. (tick.set_pad() looks like it tries to do the right thing, but the padding seems to be set when the Ticks are constructed and can't be changed after that.)
这篇关于如何在tickplabel和matplotlib中的轴之间添加空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!