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.
If you don’t want to change the spacing globally (by editing your rcParams), and want a cleaner approach, try this:
ax.tick_params(axis='both', which='major', pad=15)
or for just x axis
ax.tick_params(axis='x', which='major', pad=15)
It looks like matplotlib respects these settings as rcParams:
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 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.)
This can be done using
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()