From: Fernando C. <el....@gm...> - 2009-06-07 03:52:15
|
Hi everybody! I'm new with gnuplot.py... I'll try not to ask a newbie question... I'm now working on an engineering problem of differential equations. I use numpy and I have to plot a surface, that is the solution of the problem. A piece of code of the project: def funhomo(x,t): return eigenvector[0,0]*cos(wfrec*t)*sin(pi*x/(2*L))+eigenvector[1,0]*cos(wfrec*t)*sin(3*pi*x/(2*L))+eigenvector[2,0]*cos(wfrec*t)*sin(5*pi*x/(2*L)) it=int(raw_input("ingrese numero de puntos a obtener: ")) xinicial=0 tinicial=0 hx=float(raw_input("ingrese paso de x: ")) ht=float(raw_input("ingrese paso de t: ")) funclst=[] x0 = xinicial t0 = tinicial for i in range(0,it+1): x=x0 for j in range(0,it+1): t=t0 f=funhomo(x,t) t0=t+ht #print x,t,f funclst.append([x,t,f]) t0 = tinicial x0=x+hx print funclst As you can see, this piece makes a arrange (funclst) with a list of points (t and x) and the function (funhomo) evaluated in those points. Here, you can see an output, for it=2 and hx=ht=1 [[0, 0, 0.0], [0, 0, 0.0], [0, 0, 0.0], [1.0, 0, 3.1415924394448096e-05], [1.0, 0, 3.1415924394448096e-05], [1.0, 0, 3.1415924394448096e-05], [2.0, 0, 6.2831848757889894e-05], [2.0, 0, 6.2831848757889894e-05], [2.0, 0, 6.2831848757889894e-05]] The first element of each vector is the x. The second, the t (or y in a plot) and the third is the z=funhomo(x,t). I've tried to plot those points with gnuplot.py, but i can't! If i use gp = Gnuplot.Gnuplot(debug=1) gp.clear() gp('set data style lines') gp.splot(funclst) I got a line draw and this Warning: empty y range [0:0], adjusting to [-1:1]. However, i tried to export a "point list" and plot them with gnuplot. But i got a plot of the points, and i don't know how to draw the surface (the mesh between points). Any idea? Thanks! -- Fernando Cladera <el....@gm...> |
From: Fernando C. <el....@gm...> - 2009-06-07 04:09:23
|
There was a bad indented line (t0 = tinicial)... Sorry! This is the code. I could add the plotting, but i couldn't draw the surface. def funhomo(x,t): return eigenvector[0,0]*cos(wfrec*t)*sin(pi*x/(2*L))+eigenvector[1,0]*cos(wfrec*t)*sin(3*pi*x/(2*L))+eigenvector[2,0]*cos(wfrec*t)*sin(5*pi*x/(2*L)) it=int(raw_input("ingrese numero de puntos a obtener: ")) xinicial=0 tinicial=0 hx=float(raw_input("ingrese paso de x: ")) ht=float(raw_input("ingrese paso de t: ")) funclst=[] x0 = xinicial t0 = tinicial for i in range(0,it+1): x=x0 for j in range(0,it+1): t=t0 f=funhomo(x,t) t0=t+ht print x,t,f funclst.append([x,t,f]) t0 = tinicial x0=x+hx #print funclst gp = Gnuplot.Gnuplot(debug=1) gp.clear() plot1 = Gnuplot.PlotItems.Data(funclst, with_="points", title="Superficie") gp.splot(plot1) -- Fernando Cladera <el....@gm...> |
From: Benny M. <ben...@gm...> - 2009-06-08 07:41:34
|
2009/6/7 Fernando Cladera <el....@gm...>: > There was a bad indented line (t0 = tinicial)... Sorry! > This is the code. I could add the plotting, but i couldn't draw the > surface. Look at the examples in the demo.py file Benny > > def funhomo(x,t): > return > eigenvector[0,0]*cos(wfrec*t)*sin(pi*x/(2*L))+eigenvector[1,0]*cos(wfrec*t)*sin(3*pi*x/(2*L))+eigenvector[2,0]*cos(wfrec*t)*sin(5*pi*x/(2*L)) > > it=int(raw_input("ingrese numero de puntos a obtener: ")) > xinicial=0 > tinicial=0 > hx=float(raw_input("ingrese paso de x: ")) > ht=float(raw_input("ingrese paso de t: ")) > > funclst=[] > x0 = xinicial > t0 = tinicial > for i in range(0,it+1): > x=x0 > for j in range(0,it+1): > t=t0 > f=funhomo(x,t) > t0=t+ht > print x,t,f > funclst.append([x,t,f]) > t0 = tinicial > x0=x+hx > #print funclst > > gp = Gnuplot.Gnuplot(debug=1) > gp.clear() > plot1 = Gnuplot.PlotItems.Data(funclst, with_="points", > title="Superficie") > gp.splot(plot1) > > -- > Fernando Cladera <el....@gm...> > > > ------------------------------------------------------------------------------ > OpenSolaris 2009.06 is a cutting edge operating system for enterprises > looking to deploy the next generation of Solaris that includes the latest > innovations from Sun and the OpenSource community. Download a copy and > enjoy capabilities such as Networking, Storage and Virtualization. > Go to: http://p.sf.net/sfu/opensolaris-get > _______________________________________________ > Gnuplot-py-users mailing list > Gnu...@li... > https://lists.sourceforge.net/lists/listinfo/gnuplot-py-users > |
From: Alan G I. <ai...@am...> - 2009-06-07 19:03:47
|
On 6/6/2009 11:55 PM Fernando Cladera apparently wrote: > [[0, 0, 0.0], [0, 0, 0.0], [0, 0, 0.0], [1.0, 0, > 3.1415924394448096e-05], [1.0, 0, 3.1415924394448096e-05], [1.0, 0, > 3.1415924394448096e-05], [2.0, 0, 6.2831848757889894e-05], [2.0, 0, > 6.2831848757889894e-05], [2.0, 0, 6.2831848757889894e-05]] > I got a line draw and this > Warning: empty y range [0:0], adjusting to [-1:1]. Which is a remarkably specific and accurate warning. Look at the second element in each data point. Cheers, Alan Isaac |