views:

70

answers:

2

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.

+1  A: 

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.

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 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.)

abjennings
A: 

For completeness I'll add that it's also also possible to use set_pad but you then have to reset the label...

for tick in ax.get_xaxis().get_major_ticks():
    tick.set_pad(8.)
    tick.label1 = tick._get_text1()

But this is ugly, and in my opinion, it's nicer to just use set rcParams before creating the plot as abjennings suggests.

tom10