Change ticks font size with API

Hi,

I want to change the font size of x ticks labels.
The FAQ entry is only for pylab:
http://matplotlib.sourceforge.net/faq.html#TEXTOVERLAP

I found this solution:

    for tick in ax.xaxis.get_major_ticks():
        tick.label1.set_fontsize(7.5)
(http://cfa-www.harvard.edu/~jbattat/computer/python/pylab/)

What is the prefered way? Maybe without a loop...

  Thomas

···

--
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de

There is no preferred way -- the loop is the object oriented pythonic
matplotlib API, the set call is the matlab-like procedural interface.
Both are and will continue to be supported. Note that the FAQ is out
of date since the set function (a matlab name) is now called setp to
avoid clashing with the python built-in set

Personally, I use

  for label in ax.get_xticklabels() + ax.get_yticklabels():
      label.set_fontsize(12)

You can also set the defaults with your rc settings

  import matplotlib
  matplotlib.rc('xtick', labelsize=12)
  matplotlib.rc('ytick', labelsize=12)

which will affect all subsequent figures.

JDH

···

On Fri, Oct 10, 2008 at 4:17 AM, Thomas Guettler <hv@...2175...> wrote:

Hi,

I want to change the font size of x ticks labels.
The FAQ entry is only for pylab:
http://matplotlib.sourceforge.net/faq.html#TEXTOVERLAP

I found this solution:

   for tick in ax.xaxis.get_major_ticks():
       tick.label1.set_fontsize(7.5)
(http://cfa-www.harvard.edu/~jbattat/computer/python/pylab/)

What is the prefered way? Maybe without a loop...