From: <kai...@t-...> - 2003-11-08 21:28:38
|
This is easy using just Python features (no special support from Gnuplot.py required): Under any Python version: apply(g.plot, plot_list) Under recent Python versions (starting at 2.0?): g.plot(*plot_list) Either of these takes the elements of the sequence as individual arguments to the g.plot() method. Michael Nate Gelbard wrote: >I have a database query that returns a variable length list of hosts for >which I want to plot some data about. >How can I pass Gnuplot.plot a list of Gnuplot.Data types? >In the past I knew how may lines I had on the graph so I could just pass >g.plot(gd1,gd2,gd3,gd4) .... how do I >make a variable length variable list? > >I was trying this but got a TypeError: bad argument type for built-in >operation > > plot_list = [] > for i in res.keys(): > print i > x = Numeric.arange(len(res[i]),typecode=Numeric.Float) > y = Numeric.zeros(len(res[i])) > for j in range(0,len(res[i])): > line = res[i] > y[j] = line[j][0] > gd = Gnuplot.Data(x,y,title=i,smooth=smoothtype) > plot_list.append(gd) > g.plot(plot_list) > > -- Michael Haggerty mh...@al... |