From: Simon C. <ss...@ma...> - 2004-07-10 17:25:05
|
Hi Nate, >From Nate Gelbard <gelbardn@tr...> 2003-11-06 22:53: > 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? Sorry I can't reply to the exact thread, I just joined the list. I had this problem today and my solution was to use eval(): # plot contents of dKGrid[][] against xKGrid[] pobj = Gnuplot.Gnuplot() # Snipped out formatting stuff... gpd = [] # Array of plot objects. gpdStr = "" # String listing them as arguments for i in xrange( 0, len( yKGrid ) ): # Make a list of plot objects gpd.append( Gnuplot.Data( xKGrid, dKGrid[i] ) ) if i > 0: gpdStr += ", " # Comma separate them ... gpdStr += 'gpd[%d]' % (i) # as a list of arguments eval( 'pobj.plot( ' + gpdStr + ')' ) # Execute the plot command pobj.reset() Bit late, but I hope this helps... -- Simon -- Simon Clift E-mail: ssclift at math dot uwaterloo dot ca Ph.D. Student Scientific Computation Group University of Waterloo Waterloo, Ontario, Canada N2L 3G1 |