|
From: Michael H. <mh...@ka...> - 2004-07-27 20:26:20
|
Simon Clift wrote:
>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?
>>
>>
>I had this problem today and my solution was to use eval():
>
>
[...]
It is rarely necessary to resort to eval(). In this case, just set up
the gpd array the way you did and then use eval(). Here I have modified
your code as described:
> # plot contents of dKGrid[][] against xKGrid[]
>
> pobj = Gnuplot.Gnuplot()
>
> # Snipped out formatting stuff...
>
> gpd = [] # Array of plot objects.
>
> for i in xrange( 0, len( yKGrid ) ):
>
> # Make a list of plot objects
>
> gpd.append( Gnuplot.Data( xKGrid, dKGrid[i] ) )
>
> apply(pobj.plot, gpd) # Execute the plot command
> pobj.reset()
>
>
With newer version of Python (starting with 2.0?) you can use the new syntax
pobj.plot(*gpd)
Michael
--
Michael Haggerty
mh...@al...
|