applying format to numbering

Hi, It's me again ... I still do not find my way out of

    > the problem on how I can apply a format to the
    > numbering of an axis. I am using the WXAgg backend and
    > this is my code:

To apply a "default font" for the entire figure, you can use the rc
params -- see http://matplotlib.sf.net/.matplotlibrc, especially the
font.*, axes.* and tick.* settings

    from matplotlib import rc
    from pylab import figure, show

    rc('font', weight='bold', style='italics')
    rc('axes', labelsize=25)
    rc('tick', labelsize=14)

    fig = figure()
    ax = fig.add_subplot(111)
    ax.plot(range(10))
    ax.set_xlabel('hi')
    ax.set_ylabel('bye')
    ax.set_title('easy as 1-2-3')

    show()

You can also customize the default tick labels sizes individually. I
already noted that for the xlabel, ylabel and title you can use
kwargs, eg

    ax.set_xlabel('hi', fontsize='smaller')

and so on.

For the tick labels, you will need to get a list of the tick label
Text instances you want to customize

  labels = ax.get_xticklabels()

You can call any of the text setter methods on these labels, which are
detailed here
http://matplotlib.sourceforge.net/matplotlib.text.html#Text

For example, you can set the fontsize or fontproperty with

for label in labels:
    label.set_fontsize(mysize)

for label in labels:
    label.set_fontproperties(fp)

A lot of the methods like set_fontsize are historical artifacts from
before we had font properties, and they just forward the call to the
property

If you want finer grained control over the major and minor ticks, or
different customizations for the top and bottom ticks (on the xaxis
the top ticks are normally off but you can turn them on) you can do
that too, but it is a little more work

  # ditto for get_minor_ticks
  ticks = ax.xaxis.get_major_ticks()
  majLabelsLower = [tick.label1 for tick in ticks]
  majLabelsUpper = [tick.label2 for tick in ticks]

and then call the setter methods on these as above.

Hope this helps,
JDH

Hi,

Thanks John and Ken for your detailed replies. They came almost immediately, but since I'm 6-7 hours ahead of you and the weekend was approaching this answer took a bit longer ...

Anyway, now everything is working - finally I've got it. In contrast to your advise, John, I rather don't change the rc-file, for this not such a good idea if one wants to distribute the software at some point among colleagues.

May I still add a different question? As you know I'm using the WXAgg backend (at least in some of my scripts) and embedded essentially everything like in the example scripts:

class SAXS_wx(wx.Frame):
  def __init__(self,parent,id,title):
    wx.Frame.__init__(self,None,-1,"SPlot")
<snip>
    self.fig = Figure(figsize=(5,4),dpi=100)
    self.axes = self.fig.add_subplot(111)
    self.canvas = FigureCanvas(self, -1, self.fig)
    self.parent = self.canvas.GetParent()
    self.canvas.mpl_connect('motion_notify_event',self.mouse_move)
    sizer = wx.BoxSizer(wx.VERTICAL)
    self.sizer = sizer
    sizer.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.GROW|wx.EXPAND)
    
    self.add_splot_toolbar()
    
    self.SetSizer(self.sizer)
    self.Fit()

Now, changing the figsize parameter has absolutely no effect on the canvas size whatsoever. Does anybody know how to change the figure size? Currently I only get a beautifully, tiny window every user needs to expand by hand ...

Once more for the record: I'm stuck with matplotlib 0.71 on Panther (OS X 10.3) with Apple's framework Python 2.3 for a while.

Thanks,
Christian

I have been unable to reproduce this behavior using matplotlib 0.72 under OS X 10.3.9 with wxPython 2.6.0.0. What version of wxPython are you running?

Ken

···

On May 28, 2005, at 6:24 AM, Christian Meesters wrote:

Now, changing the figsize parameter has absolutely no effect on the canvas size whatsoever. Does anybody know how to change the figure size? Currently I only get a beautifully, tiny window every user needs to expand by hand ...

Hm, 2.5.3.1. I know it's time to update my system, but this will have to wait for a while. I need to coordinate several modules / versions.

Anyway, thanks for looking into this. If it is really related to my wx version, there is no solution for me now. But then again, if I move my stuff to an updated Linux system soon, there should be no problem (at least not with wx ...).

Thanks,
Christian

···

On 28 May 2005, at 17:20, Ken McIvor wrote:

On May 28, 2005, at 6:24 AM, Christian Meesters wrote:

Now, changing the figsize parameter has absolutely no effect on the canvas size whatsoever. Does anybody know how to change the figure size? Currently I only get a beautifully, tiny window every user needs to expand by hand ...

I have been unable to reproduce this behavior using matplotlib 0.72 under OS X 10.3.9 with wxPython 2.6.0.0. What version of wxPython are you running?

Ken