[SciPy-user] drawing time
Travis E. Oliphant
oliphant.travis at ieee.org
Thu Mar 13 17:11:23 EST 2003
Johannes Broedel wrote:
> Hallo,
>
> thanks for the short progrma, trying ade my computer producing the
> following message (IPython):
>
> In [7]: run sciptest.py
> ---------------------------------------------------------------------------
>
> MemoryError Traceback (most recent call
> last)
>
> /home/jbroedel/python/graphtest/sciptest.py
> 5 xplt.hold('on')
> 6 for xval in x:
> 7 yval = sin(xval / 4)
> ----> 8 xplt.plot(xval, yval, 'x')
> 9 xplt.pause(100)
>
> /home/python/PYTHON/lib/python2.2/site-packages/scipy/xplt/Mplot.py in
> plot(x, *args, **keywds)
> 480 y = scipy.real(y)
> 481 y = where(scipy.isfinite(y),y,0)
> --> 482
> gist.plg(y,x,type=thetype,color=thecolor,marker=themarker,marks=tomark,width=linewidth)
>
> 483
> 484 nowplotting = nowplotting + 1
This looks the problem I had when I first tried the little test program.
For me, it was because y and x are scalars (not 1-d arrays) (and the
xplt.plot program uses squeeze so that even if you try to give it [x] it
will turn the 1-d array with one element into a scalar).
Gists plg can't use scalars. This xplt.plot problem was fixed in CVS
two days ago.
>
> MemoryError:
> WARNING: Failure executing file: <sciptest.py>
>
> The real problem I had was with the following program:
>
> #!/usr/bin/env python
>
> from Numeric import *
> from scipy.xplt import *
>
>
> def standard_map(x_cor,y_cor,kappa):
> """provide one interate of the inital conditions x_cor,y_cor
> for the standard map with parameter kappa.
> """
> y_cor_new=(y_cor-kappa*sin(2.0*pi*x_cor) )% 1
> x_cor_new=(x_cor+y_cor_new ) % 1
>
> return(x_cor_new,y_cor_new)
The code you had worked for me on my system (I'm not sure what it's
supposed to do, but it generated points on the page).
A couple of things (aside from the indentation problems I had when your
code came through the email)
1) I would recommend using plot instead of plg. Plot hides some of the
oddities and use a MATLAB-style syntax
for plottin characters.
2) I wouldn't use points for a test like this (they can be very hard to
see). I used the following code:
if __name__ == '__main__':
window() # initialize plotting
limits(0.0,1.0,0.0,1.0)
x,y=0.5,0.1 # initial (x,y)
k=1.1/(2.0*pi) # parameter
animate(0)
iterations=1000
xplt.hold('off')
xplt.fma()
xplt.hold('on')
while 1: # iterate initial conditions
for i in range(iterations):
(x,y)=standard_map(x,y,k)
plot(x,y,'bx') # The b
means blue, the x means make an x symbol at the point.
ch=mouse(-1,0,"press mouse button")
x,y=ch[0],ch[1]
if(ch[9]==3): break # mouse key 3
plg(array([y]),array([x])) # I don't now what this is supposed
to do.
-Travis O.
More information about the SciPy-User
mailing list