From: Louis P. <pe...@an...> - 2006-06-01 17:52:44
|
Christopher Barker wrote: > Louis, > > This is standard num* array behavior: arrays are mutable, and MPL is > not making copies of them when you plot, which is a good thing. > > by the way, slices of arrays are references too, which is different > than python lists, so it can be surprising, but also useful > >> # 1st Plot ................. >> x[0]= 1.0 >> y[0]= 1.0 >> x[1]=-1.0 >> y[1]=-1.0 >> a.plot(x,y) >> >> # 2nd Plot ................. > > now you need copies. You can make brand new ones, or use the copy() > method: > x = x.copy() > y = y.copy() > > you could also pass a copy into the plot method: > > a.plot(x.copy(), y.copy()) > > which is perhaps the behavior you were expecting. > > -Chris Thanks, Chris. I sort of figured this out, but you put it clearer and I like the copy suggestion. I'll use it. It sure drove me nuts for a while. :-) -- Cheers, Lou Pecora Code 6362 Naval Research Lab Washington, DC 20375 USA Ph: +202-767-6002 email: pe...@an... |