Ticklabels

Dear all,

I find it incredibly hard to work with tick labels in matplotlib (on matplotlib 0.98 @ OS X 10.5.4) (It might well be that I haven't stumbled across the right solution yet and it is really easy :wink: ). I want to first of all change the axis so it displays the normal number as ticks and not 0, 1 ,2 ,3 + 6.35e5 or something. I managed that by reading the ticks and then converting it to strings and use the set_ticklabels to get that. The second thing is that I want to make the font smaller, e. g. to 'x-small' at the moment I am using a for loop to loop through all xticklabels which is allright but imho looks to complicated to do something as simple as that.
I also want to change the padding between the axis and the labels, but all my attempts at finding the set_pad method have failed because none of the axis objects I could think of had that method.
So here's my workaround for the first two things (each subplot is one small window of 6 subplots):

#preparing the subplots()
figure=gcf()
subplots=[]

for i in range(6):
聽聽聽聽聽subplots.append(figure.add_subplot(23*10+i+1))

for i,line in enumerate(line_data):
聽聽聽聽聽subplots[i].axes.ticklabel_format(style='sci',axis='x')
聽聽聽聽聽subplots[i].plot(line[:,0],line[:,1])
聽聽聽聽聽new_ticks=map(str,subplots[i].axes.get_xticks())
聽聽聽聽聽subplots[i].axes.set_xticklabels(new_ticks)
聽聽聽聽聽for ilabel in subplots[i].axes.get_xticklabels():
聽聽聽聽聽聽聽聽聽ilabel.set_fontsize('x-small')

路路路

----------------------
Oh and while I'm at it: Is there a function that plots a two dimensional array?

Thanks in advance
聽聽聽聽聽聽Wolfgang

P.S.: I already looked through the mailing list for the padding issue but it only mentioned set_pad which I could not find

Dear all,

I find it incredibly hard to work with tick labels in matplotlib (on
matplotlib 0.98 @ OS X 10.5.4) (It might well be that I haven't
stumbled across the right solution yet and it is really easy :wink: ). I

Sorry you are having trouble - -suggestions below

want to first of all change the axis so it displays the normal number
as ticks and not 0, 1 ,2 ,3 + 6.35e5 or something. I managed that by

You can also just set your own format string:

  import matplotlib.ticker as ticker
  ax.yaxis.set_major_formatter(ticker.FormatStrFormatter('%1.2f')

reading the ticks and then converting it to strings and use the
set_ticklabels to get that. The second thing is that I want to make
the font smaller, e. g. to 'x-small' at the moment I am using a for
loop to loop through all xticklabels which is allright but imho looks
to complicated to do something as simple as that.

You can also set the rc parameter

  import matplotlib
  matplotlib.rcParams['ytick.major.size'] = 'x-small'

and likewise for minor ticks.

I also want to change the padding between the axis and the labels, but
all my attempts at finding the set_pad method have failed because none
of the axis objects I could think of had that method.

Did you try setting the rc parameter

  matplotlib.rcParams['ytick.major.pad'] =6

An example rc is at http://matplotlib.sf.net/matplotlibrc. You can
drop this in ~/.matplotlib and make these customizations permanent if
you want.

Oh and while I'm at it: Is there a function that plots a two
dimensional array?

ax.imshow plots images

路路路

On Mon, Jul 21, 2008 at 4:54 AM, Wolfgang Kerzendorf <wkerzendorf@...982...> wrote: