Using coordinate mappings
It is possible, when making 3D plots from data files, for the data to be interpreted in spherical or cylindrical coordinates rather than the default Cartesian system. For details, type help set mapping
. We will give an example of using the cylindrical mapping to conveniently draw a shape with cylindrical symmetry.
The previous figure is a perspective view of a surface that somewhat resembles a Christmas tree ornament. The relevant feature of this surface is that it has rotational symmetry around the z (vertical) axis, which means that it is most naturally expressed in cylindrical coordinates.
How to do it…
Try the following script:
set mapping cylindrical
unset tics
unset border
set hidden
set xrange [-pi : pi]
set yrange [-pi : pi]
set zrange [0 : pi]
set iso 60
unset key
splot '++' using 1:2:(sin($2)) with lines
How it works…
There are several new ideas used in this recipe. Breaking it down, these are:
The set mapping command
The first, highlighted line contains the...