From: Michael H. <mh...@ka...> - 2004-06-26 08:23:44
|
To get blank lines in the data that is sent to gnuplot, put your data into a 3-d array then pass the array to Gnuplot.Data. In other words, you currently have x = [1,1,1,2,2,2,3,3,3,4,4,4] y = [1,2,3,1,2,3,1,2,3,1,2,3] z = [z(1,1),z(1,2),z(1,3),z(2,1),...] val = [val(1,1), ...] Instead, create an array as follows: data = [ [ [1,1,z(1,1),val(1,1)], [1,2,z(1,2),val(1,2)], [1,3,z(1,3),val(1,3)], ], [ [2,1,z(2,1),val(2,1)], [2,2,z(2,2),val(2,2)], [2,3,z(2,3),val(2,3)], ], ... ] Then plot the data with resG.splot(Gnuplot.Data(data)) You could create the data array from your old lists using something like (untested!): data = Numeric.asarray([x,y,z,val], Numeric.Float32) # Change the order of the indices to "zip" the arrays together: data = Numeric.transpose(set, (1,0)) data = Numeric.reshape((4,3,4,), data) If you generate the data using functions (and if you are using python 2 or above), an even easier way would be to use data = [[[x,y,z(x,y),val(x,y)] for y in yvals] for x in xvals] Hope that helps. Michael Marc Hodapp wrote: > when using gnuplot directly, I can create 4d data plots with > something like: > > set pm3d > splot 'file.dat' using 1:2:3:4 > > Where file.dat is the data file, 1,2,3 are the columns with the x,y,z > data and 4 is the column with the value data which defines the color > value. > > Now I want to do the same thing using gnuplot.py. In my python > program, I define 4 lists: x, y,z,val. I then use the instructions: > > resG = Gnuplot.Gnuplot() > resG('set pm3d') > resG.splot(Gnuplot.Data(x,y,z,val)) > > What I get as a result, is a 3d plot with my points, but no colored > surface showing val . So my questions are: Can Gnuplot.Data() receive > 4 arguments, which are then passed to splot and pm3d? When using > gnuplot directly, the file must contain blank lines between two scans > (isolines). In gnuplot.py do I have to include empty strings in the > x,y,z,val lists to delimit the isolines? How can I delimit these scans > in gnuplot.py? Is there an other way to plot my surface using the > xyz,val lists ( like resG('splot ...') )? -- Michael Haggerty mh...@al... |