Thanks Ben. Your solution for setting different fontsizes worked like a charm!

For the other question, what I meant by padding was the distance of the tick label from the axis. This is what I set with the following command:

matplotplib.pyplot.rc(('xtick.major','ytick.major'), pad=10)

so that the pad of the label from the axis is set to 10. Now what if I want to set the pad of just one of the xtick lables to a different value?


On 03/01/2012 01:17 PM, Benjamin Root wrote:

On Thu, Mar 1, 2012 at 11:33 AM, Pawel <> wrote:
Hi all,

Is it possible to set the size of only some tick labels? I have text
tick labels (residue names). I'd like to reduce the font size of just
two of the labels to make them fit better, but keep the size of the
remaining labels the same.

It isn't _impossible_, but mpl certainly won't make it easy for you.  After creating your graph and tick labels, you would have to get back the tick labels as a list of Text objects using "get_xticklabels()".  Then, you modify the font size of the appropriate element in that list.  Perhaps something like this:

xticks = ax.get_xticklabels()
xticks[3].set_fontsize(xticks[3].get_fontsize() * 0.9)

Note: Completely untested.
And in a similar vein, is it possible to change the padding of just some
tick labels? Again, I'd like to increase the padding of just two of the
labels but keep the remaining the same.

By "padding" are you referring to the spacing between the tick labels?  That would have to be done by changing the tick locations themselves.  By default, the ticks are equally spaced over the specified domain, and the labels for those ticks are placed so that the center lines up with the tick mark.  Try using "get_xticks()" and "set_yticks()" and see what happens.

I hope that helps!
Ben Root