|
From: Jakob J. L. <jak...@gm...> - 2006-04-17 14:42:27
|
Thanks John & Ryan,
I'm sitting here in Germany, Berlin, trying to get some data-analysis
up to par during the Easter holidays and can't get over the fact that
I'm getting help from around the globe, within minutes.
It seems to work now!
Jakob
On 4/17/06, Ryan Krauss <rya...@gm...> wrote:
> Here is an example that works for me doing this as John mentioned
> (figure 2) or the first way that came to my mind (figure 1):
>
> from numpy import zeros, arange, sin, cos, pi
> from pylab import figure, subplot, plot, show, cla, clf
> t=3Darange(0,1,0.01)
> y=3Dzeros([len(t),4],'d')
> y[:,0]=3Dsin(2*pi*t)
> y[:,1]=3Dcos(2*pi*t)
> y[:,2]=3Dsin(2*pi*t*2+1)
> y[:,3]=3Dcos(2*pi*t*2+1)
>
> nc=3D1
> nr=3D4
>
> figure(1)
> clf()
> for x in range(nr):
> subplot(nr,1,x+1)
> plot(t,y[:,x])
>
> figure(2)
> clf()
> for x in range(nr):
> ax =3D figure(2).add_subplot(nr, 1, x+1)
> ax.hold(False)
> ax.plot(t,y[:,x])
> if ax.is_last_row():
> ax.set_xlabel('time')
>
> show()
>
>
> On 4/17/06, John Hunter <jdh...@ac...> wrote:
> >
> > You seem to be mixing idioms, between pylab which manages current
> > figure and current axes, and explicitly managing the Figure and Axes
> > instances yourself. Eg
> >
> > fig =3D figure()
> > hold(False) #<-- manipulates current axes
> > for counter in counter_list:
> > y =3D intensities_calc[counter]
> > plotnr =3D plotnr+1
> > ax =3D subplot(rownrs, colnrs, plotnr) #<-- uses curren=
t fig
> > fig.add_subplot(ax)
> > plot(x,y) #<-- uses current axes
> > if ax.is_last_row():
> > ax.set_xlabel('time')
> >
> > If you want to manage the figure and axes attributes yourself, which
> > is good practice, I suggest imposing some discipline on yourself and
> > only importing 4 things from pylab (this is what I usually do)
> >
> > from pylab import figure, show, nx, close
> >
> > Your code would then look something like:
> >
> > fig =3D figure()
> > for counter in counter_list:
> > y =3D intensities_calc[counter]
> > plotnr =3D plotnr+1
> > ax =3D fig.add_subplot(rownrs, colnrs, plotnr)
> > ax.hold(False)
> > ax.plot(x,y)
> > if ax.is_last_row():
> > ax.set_xlabel('time')
> >
> > That should work, as long as plotnr is incrementing like you expect it
> > to.
> >
> > JDH
> >
> >
> > -------------------------------------------------------
> > This SF.Net email is sponsored by xPML, a groundbreaking scripting lang=
uage
> > that extends applications into web and mobile media. Attend the live we=
bcast
> > and join the prime developer group breaking into this new coding territ=
ory!
> > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&dat=
=3D121642
> > _______________________________________________
> > Matplotlib-users mailing list
> > Mat...@li...
> > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
> >
>
--
Jakob J. Lopez (Jak...@gm...)
|