Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matplotlib set yaxis label size

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) 

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.

I've tried, for example:

pylab.gca().get_ylabel().set_fontsize(60) 

but I only get:

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.

like image 597
zje Avatar asked May 01 '12 21:05

zje


People also ask

How do you change axis label size?

You can change axis text and label size with arguments axis. text= and axis. title= in function theme() . If you need, for example, change only x axis title size, then use axis.

How do I make axis labels bigger in Matplotlib?

The size and font of title and axes in Matplotlib can be set by adjusting fontsize parameter, using set_size() method, and changing values of rcParams dictionary.


1 Answers

If you are using the 'pylab' for interactive plotting you can set the labelsize at creation time with pylab.ylabel('Example', fontsize=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).

like image 152
bmu Avatar answered Oct 06 '22 23:10

bmu