using subplot to plot a large numbers of graphs in a loop

Hello,

It may very well be that this is a trivial problem, due to my lack of
knowledge. I did, at least, go through all the mail lists and the
examples of pylab (VERY NICE, BTW: I am extremely happy to have found
it).

I am trying to plot a table or matrix of graphs. I want to do this
with a loop. So far, I have tried it with something like

## code starts here
        rownrs = ... # defined nr of graphs in x direction
        colnrs = ... # defined nr of graphs in y direction
        x = .... # defined x-values here
        plotnr = 0
  fig = figure()
  hold(False)
  for counter in counter_list:
    y = intensities_calc[counter]
    plotnr = plotnr+1
    ax = subplot(rownrs, colnrs, plotnr)
    fig.add_subplot(ax)
    plot(x,y)
    if ax.is_last_row():
    ax.set_xlabel('time')
  show()

### code ends here

all i get is one graph, in the first position. no error messages.

please, what am i doing wrong ?

very grateful for an answer..

Jakob

···

--
Jakob J. Lopez (JakobJLopez@...287...)

I think you need to replace plot(x,y) with ax.plot(x,y).

I think this script could be slightly simpler if you used the pylab
interface to matplotlib so that you could just call figure, subplot,
and plot without having to specify the axis.

But if this is your first attempt at using matplotlib, you have done a
fairly impressive job at searching the examples and archives first.

Ryan

···

On 4/17/06, Jakob J. Lopez <jakobjlopez@...287...> wrote:

Hello,

It may very well be that this is a trivial problem, due to my lack of
knowledge. I did, at least, go through all the mail lists and the
examples of pylab (VERY NICE, BTW: I am extremely happy to have found
it).

I am trying to plot a table or matrix of graphs. I want to do this
with a loop. So far, I have tried it with something like

## code starts here
        rownrs = ... # defined nr of graphs in x direction
        colnrs = ... # defined nr of graphs in y direction
        x = .... # defined x-values here
        plotnr = 0
        fig = figure()
        hold(False)
        for counter in counter_list:
                y = intensities_calc[counter]
                plotnr = plotnr+1
                ax = subplot(rownrs, colnrs, plotnr)
                fig.add_subplot(ax)
                plot(x,y)
                if ax.is_last_row():
                ax.set_xlabel('time')
        show()

### code ends here

all i get is one graph, in the first position. no error messages.

please, what am i doing wrong ?

very grateful for an answer..

Jakob

--
Jakob J. Lopez (JakobJLopez@...287...)

-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmdlnk&kid0944&bid$1720&dat1642
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
matplotlib-users List Signup and Options

Hi Ryan,

Thanks for that very quick email and the encouragement.

Sadly, using ax.plot doesnt solve my problem.. no change in output...

Jakob

···

On 4/17/06, Ryan Krauss <ryanlists@...287...> wrote:

I think you need to replace plot(x,y) with ax.plot(x,y).

I think this script could be slightly simpler if you used the pylab
interface to matplotlib so that you could just call figure, subplot,
and plot without having to specify the axis.

But if this is your first attempt at using matplotlib, you have done a
fairly impressive job at searching the examples and archives first.

Ryan

On 4/17/06, Jakob J. Lopez <jakobjlopez@...287...> wrote:
> Hello,
>
> It may very well be that this is a trivial problem, due to my lack of
> knowledge. I did, at least, go through all the mail lists and the
> examples of pylab (VERY NICE, BTW: I am extremely happy to have found
> it).
>
> I am trying to plot a table or matrix of graphs. I want to do this
> with a loop. So far, I have tried it with something like
>
> ## code starts here
> rownrs = ... # defined nr of graphs in x direction
> colnrs = ... # defined nr of graphs in y direction
> x = .... # defined x-values here
> plotnr = 0
> fig = figure()
> hold(False)
> for counter in counter_list:
> y = intensities_calc[counter]
> plotnr = plotnr+1
> ax = subplot(rownrs, colnrs, plotnr)
> fig.add_subplot(ax)
> plot(x,y)
> if ax.is_last_row():
> ax.set_xlabel('time')
> show()
>
> ### code ends here
>
> all i get is one graph, in the first position. no error messages.
>
> please, what am i doing wrong ?
>
> very grateful for an answer..
>
> Jakob
>
> --
> Jakob J. Lopez (JakobJLopez@...287...)
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting language
> that extends applications into web and mobile media. Attend the live webcast
> and join the prime developer group breaking into this new coding territory!
> http://sel.as-us.falkag.net/sel?cmdlnk&kid0944&bid$1720&dat1642
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> matplotlib-users List Signup and Options
>

--
Jakob J. Lopez (JakobJLopez@...287...)