From: Juho S. <juh...@as...> - 2005-07-01 07:55:55
|
Hi, I think g.plot() eats Gnuplot.Data objects, not lists. So you can have g.plot(data1, data2, ... dataN) but not g.plot([data1, data2, ... dataN]) Copies of all input to g.plot is added to g.itemlist... after the command above you have g.itemlist as [data1, data2, ..., dataN]. To add a line to the plot after g.plot(data) you could use newdata = Gnuplot.Data(whateveryouhave) g.replot(newdata) Now the itemlist would be [data1, data2, ..., dataN, newdata]. The way I remove stuff from the itemlist is a bit ugly. If you know the position of the unwanted item in the datalist (here assumed 1), you can do del g.itemlist[1] This does not delete you data, only the copy stored in the itemlist. After del, the itemlist would be [data1, data3, ..., dataN, newdata] Then use g.refresh() to update the plot and data2 is no longer visible. For this you need your own bookkeeping on the data in itemlist, to know the indices. If the itemlist goes empty you might get trouble. -- Juho Schultz e-mail: juh...@as... www.astro.helsinki.fi/~jschultz Observatory P.O. Box 14 FIN-00014 University of Helsinki FINLAND On Thu, 30 Jun 2005, Steven Waldauer wrote: > >I have a pretty simple script working right now, and I'm still >relatively new to python so if I'm going at this in a stupid way, >please let me know. > >right now it has the following: > > a_mag = Gnuplot.Data(w, cols=(1,6), inline=1) > a_mag.set_option(title='Amide Dipole') > a_mag.set_option(with='lines') > > mags.append(a_mag) > > s_mag = Gnuplot.Data(w, cols=(1,10), inline=1) > s_mag.set_option(title='Side Chain Dipole') > s_mag.set_option(with='lines') > > mags.append(s_mag) > >when I use the command: > g.plot(a_mag, s_mag) > >everything works fine. I would like however to add or remove certain >plots from within the script, but alas the command: > > g.plot(mags) > >or > g.plot(tuple(mags)) > >does not work. I get the following error messages: > >Traceback (most recent call last): > File "./fasttest.py", line 215, in ? > g.plot(mags) > File "/usr/local/lib/python2.4/site-packages/Gnuplot/_Gnuplot.py", >line 273, in plot > self._add_to_queue(items) > File "/usr/local/lib/python2.4/site-packages/Gnuplot/_Gnuplot.py", >line 243, in _add_to_queue > self.itemlist.append(PlotItems.Data(item)) > File "/usr/local/lib/python2.4/site-packages/Gnuplot/ >PlotItems.py", line 513, in Data > set = utils.float_array(set[0]) > File "/usr/local/lib/python2.4/site-packages/Gnuplot/utils.py", >line 36, in float_array > return Numeric.asarray(m, Numeric.Float32) > File "/usr/local/lib/python2.4/site-packages/Numeric/Numeric.py", >line 134, in asarray > return multiarray.array(a, typecode, copy=0, savespace=savespace) >AttributeError: _InlineFileItem instance has no attribute '__float__' > >Any suggestions? > >Thanks for any help, > >Steve > > >------------------------------------------------------- >SF.Net email is sponsored by: Discover Easy Linux Migration Strategies >from IBM. Find simple to follow Roadmaps, straightforward articles, >informative Webcasts and more! Get everything you need to get up to >speed, fast. http://ads.osdn.com/?ad_id=7477&alloc_id=16492&op=click >_______________________________________________ >Gnuplot-py-users mailing list >Gnu...@li... >https://lists.sourceforge.net/lists/listinfo/gnuplot-py-users > |