axes numbers font size

Hello,

I just started looking into python and matplotlib a few days ago and I am amazed that this software can do more or less the same as MATLAB. I just have a couple of questions regarding some stuff that I spent a lot of time without figuring out.

1. Is there a way to change the font type and font size of the numbers on the axes in a figure? Not the labels (xlabel and ylabel - they are easy to change), but the actual numbers. If for example x goes from 0 to 6 in step of 2, the numbers showing below the x axis would be 0, 2, 4, and 6 for example. It is the fontsize and font of these numbers that I want to change. It must be some axis property but I cannot figure it out.

2. I will be using the figures plotted in matplotlib mainly to import them in LATEX documents. Since Latex uses Computer modern font by default, is there a way to change the default font in matplotlib to match it? What would be the actual command?

3. The data that I would like to plot is in an ASCII format, where the first row and column is text and the rest is numbers. What would be the best way to import that into maplotlib and then assign a variable name to each column (without the first entry, which would be the variable name).

Thanks a lot in advance.

···

_________________________________________________________________
Сдобий се със следващата генерация Windows Live услуги сега!
http://get.live.com

Hello,

···

On Tuesday 18 December 2007 23:42, G. O. Nikiforov wrote:

1. Is there a way to change the font type and font size of the numbers on
the axes in a figure? Not the labels (xlabel and ylabel - they are easy to
change), but the actual numbers. If for example x goes from 0 to 6 in step
of 2, the numbers showing below the x axis would be 0, 2, 4, and 6 for
example. It is the fontsize and font of these numbers that I want to
change. It must be some axis property but I cannot figure it out.

I'm not sure that this is the right solution and it does not use an axes
property, but the following works for me:
--------------------------------------------------------------------------------------------------------------
import pylab
pylab.figure()
ax = pylab.axes()
ax.plot(pylab.arange(10))
xlabels = ax.get_xticklabels()
xlabel0 = xlabels[0] # one of the xtick labels
xlabel0.get_fontsize()
xlabel0.set_fontsize(20)
pylab.show()
----------------------------------------------------------------------------------------------------------------
So finally my solution needs an iteration over a list like
--------------------------------------------------------------------------------------------------------------
for xlabel_i in ax.get_xticklabels():
    xlabel_i.set_fontsize(20)
--------------------------------------------------------------------------------------------------------------

3. The data that I would like to plot is in an ASCII format, where the
first row and column is text and the rest is numbers. What would be the
best way to import that into maplotlib and then assign a variable name to
each column (without the first entry, which would be the variable name).

Here again I can only present an work around, but maybe it helps you
nevertheless
-------------------------------------------------------------------------------------------------------
import numpy as n

fp = open('test.dat', "w")
fp.write('a b c \n') # write some example data
fp.write('X 1 2 \n')
fp.write('Y 3 4 \h')
fp.close()

fp = open('test.dat', "r")
rows = fp.readlines()
fp.close()

one_row = rows[0] # one line of the saved data
print one_row

one_row_entries = one_row.split(' ')
print one_row_entries

# one would like to do something like the following to get all numbers

XY = n.zeros((2, 2), dtype=n.int32)
for i, row in enumerate(rows[1:]): # neglecting the first rows
    xy_list = row.split(' ')[1:-1] # neglecting first column and '\n'
    # convert to array and afterwards from string to integer values
    xy_array = (n.array(xy_list)).astype(n.int32)
    XY[i, :] = xy_array

print "XY =",XY

print "X =", XY[0, :], " and Y =", XY[1, :]
---------------------------------------------------------------------------------------------------------------

best regards,
Matthias