0

I have a data file in x,y,z and want to plot a 3D cone using the data. I tried splot but it is giving only last point circle. My data file is in following format :

X   y   z 
0  18  18 
10  59  59     
20  80  80 

Any help is appreciated.

Thanks in advance -Abhi

5
  • 1
    Is that really your datafile format? (do the blank lines really exist?) Commented Feb 1, 2013 at 12:41
  • no blank lines are there in datafile...sorry for late reply - Abhi Commented Feb 4, 2013 at 6:12
  • I've updated your question to reflect the way the data actually looks. Feel free to edit it to correct if I've done anything incorrectly. As a side note, you might want to add a little more explanation about how the datafile is generated, or what it contains. As it is, it's hard to really interpret anything from just 3 points. Commented Feb 4, 2013 at 18:00
  • Thanks for updating data. Data is generated through Fresnel's Equation. This equation is used in seismic domain to get fresnel radius for a process called Migration in geophysics. Commented Feb 6, 2013 at 5:24
  • I'm a little familiar with the Fresnel Equations via optics. Maybe it will be instructive for me to just post a small script showing you how you can create a datafile that gnuplot can use to plot a cone ... We can work from there. Commented Feb 6, 2013 at 12:14

1 Answer 1

1

At this point, I think it might be easier to show a simple script that can be used to generate data in a format that gnuplot can use to plot a cone:

I'll use python for 2 reasons. First, I know it pretty well, and second, it reads pretty much like pseudo-code, so it should be pretty clear what is happening even if you don't know 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')

Now this generates a datafile data.txt. To plot this datafile in gnuplot, you can simply do:

set surface
#set hidden3d  #This makes the object "non-transparent"
splot 'data.txt' using 1:2:3 with lines
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.