From: Michael H. <mh...@al...> - 2005-05-07 03:16:53
|
Hi, The problem is a little bit obscure. You are passing splot() a 2-D array, but it really wants a 3-D array (the third axis would accomodate multiple data at each (x,y) point. Probably this should be handled better, but a solution for you is to add a third axis explicitly: g.splot(a[..., N.NewAxis]) At least that works for me. Michael Mark Thomas wrote: > I have been producing 2d arrays in python containing z values that I would > like to plot then turn into animated gifs. Up until now I have been using > gist (pli) to plot them. However, gist is very limited in the output file > formats and I can't get any of the output file formats into for example > Python Imaging Library in order to make animated gifs. So I decided to try > drawing plots with Gnuplot in python. I have tried various examples that > work in gnuplot but not when I try to put them into python. > > An example is below (adapted from > http://gnuplot.sourceforge.net/demo/pm3d.html): > > > import Gnuplot > import numarray as N > g = Gnuplot.Gnuplot(debug=1) > # set terminal png transparent nocrop enhanced font arial 8 size 420,320 > # set output 'pm3d.9.png' > g('set border 4095 lt -1 lw 1.000') > g('set view map') > g('set samples 30, 30') > #g('set isosamples 30, 30') > g('unset surface') > g('set style data pm3d') > g('set style function pm3d') > g('set ticslevel 0') > g('set title "colour map, using default rgbformulae 7,5,15 ... traditional > pm3d (black-blue-red-yellow)" 0.000000,0.000000 font ""') > g('set xlabel "x" 0.000000,0.000000 font ""') > g('set xrange [0:30] ') > g('set ylabel "y" 0.000000,0.000000 font ""') > g('set yrange [ 0:30]') > g('set y2range [ * : * ] reverse nowriteback # (currently > [-10.0000:10.0000] )') > g('set zrange [ 0.0001 : 1.00000 ] noreverse nowriteback') > g('set pm3d at b') > > > a = N.zeros([30,30]) +.3 > a[5:10,1:22] = .9 > g.splot(a) > > Any thoughts would be greatly appreciated. |