x、y、z にデータ ファイルがあり、そのデータを使用して 3D コーンをプロットしたいと考えています。splot を試しましたが、最後の点円しか表示されません。私のデータファイルは次の形式です:
X y z
0 18 18
10 59 59
20 80 80
どんな助けでも大歓迎です。
よろしくお願いします-Abhi
x、y、z にデータ ファイルがあり、そのデータを使用して 3D コーンをプロットしたいと考えています。splot を試しましたが、最後の点円しか表示されません。私のデータファイルは次の形式です:
X y z
0 18 18
10 59 59
20 80 80
どんな助けでも大歓迎です。
よろしくお願いします-Abhi
この時点で、gnuplot が円錐をプロットするために使用できる形式でデータを生成するために使用できる単純なスクリプトを示す方が簡単かもしれません。
私は 2 つの理由で Python を使用します。第一に、私はそれをかなりよく知っています.第二に、それは疑似コードのように読むことができるので、Pythonを知らなくても何が起こっているのかがかなり明確になるはずです.
import math
h = 2
points_u = map(float,range(-h,h+1)) #[-2.,-1.,0.,1.,2.]
NTHETA = 12 #number of points in theta for the cone
dtheta = 2.*math.pi/NTHETA
points_theta = [dtheta*i for i in range(NTHETA+1)] #list of points in theta
with open('data.txt','w') as fout: #open an output file for the data
for theta in points_theta:
for u in points_u:
#This is how to plot a cone parametrically
#Here I unravel the cone into it's x-y-z components
#The important part is that within the inner loop,
#we're writing data along a single theta. In other words,
#within the inner loop, we write a single straight line which
#is on the surface of the cone.
x = (h-u)/h*math.cos(theta)
y = (h-u)/h*math.sin(theta)
z = u
fout.write('%f %f %f\n'%(x,y,z))
#After the inner loop, you need to insert a blank line to let gnuplot know
#that the particular "scan" is over and it is supposed to start a new "scan"
#After all is said and done, gnuplot will connect the points.
fout.write('\n')
これでデータファイルが生成されますdata.txt
。このデータファイルを gnuplot でプロットするには、次のようにします:
set surface
#set hidden3d #This makes the object "non-transparent"
splot 'data.txt' using 1:2:3 with lines