|
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...>
|