Reputation: 45
I have a cylinder of radius = 1. I need to plot the function f(theta,z)=exp(theta-0.2*z) where theta is the azimuthal angle and z is along the height of the cylinder, how would this be plotted in gnuplot ? I would like to see the cylinder as well.
Upvotes: 2
Views: 2388
Reputation: 7627
Assuming that your function f(theta, z) gives the radial coordinate, this can be done in parametric mode, where variables u
and v
are assigned to theta
and z
, respectively:
set parametric
set urange [0:2*pi]
set vrange [-1:1]
f(u,v)=exp(u-0.2*v)
set xrange [-2:2]
set yrange [-2:2]
set zrange [-2:2]
set isosamples 100,10
splot cos(u),sin(u),v title "cylinder", \
0.01*cos(u)*f(u,v),0.01*sin(u)*f(u,v),v title "function (scaled down)"
Note I have down scaled your function (0.01*f instead of f) since it would be too large compared with the size of the cylinder otherwise.
set parametric
uses a triplet of coordinates (x,y,z) where each is given in terms of the independent variables u
and v
. In your case (cylindrical coordinates) u = theta and so x = r cos(u) and y = r sin(u); v = z. Since your function f (or 0.01*f) gives the radial coordinate, x = f * cos(u) and y = f * sin(u).
Upvotes: 4