Contour lines at constant x values
XContours, YContours, ZContours: [Automatic, 15]
|plot::Cylindrical, plot::Function3d, plot::Spherical, plot::Surface, plot::XRotate, plot::ZRotate|
XContours, YContours, ZContours: 
XContours, YContours, and ZContours cause contour lines on surface objects at constant x, y, or z-values, respectively.
By setting these attributes, many surface objects (such as implicit surfaces, function objects etc.) can be instructed to display contour lines.
By setting ZContours = [z1, z2, …], contour lines can be requested at specific places. This is demonstrated in Example 1.
ZContours = [Automatic, n] causes n contour lines to be evenly spaced along the range of z values of the object. Cf. Example 2.
A function plot by default uses height coloring and mesh lines to improve the visual display. With mesh lines disabled, height coloring is often still sufficient:
plotfunc3d(sin(x+cos(0.3*y))*cos(y), XLinesVisible=FALSE, YLinesVisible=FALSE, CameraDirection=[0,0.01,1])
To get a better depth impression, it would help in this example to add contour lines:
plotfunc3d(sin(x+cos(0.3*y))*cos(y), ZContours=[$ -1..1 step 0.25], XLinesVisible=FALSE, YLinesVisible=FALSE, CameraDirection=[0,0.01,1])
In the previous example, we set z values for the contour lines explicitly. There is an easier way of specifying equidistant lines, though, by giving the special value Automatic, followed by the number of lines to use. For example, implicit surfaces by default use 15 lines in each direction of space:
plot(plot::Implicit3d(abs(x)^3+abs(y)^3+abs(z)^3 - 1, x = -1..1, y=-1..1, z=-1..1), Axes = None, Scaling = Constrained)
To change the number of lines, we use the syntax outlined above:
plot(plot::Implicit3d(abs(x)^3+abs(y)^3+abs(z)^3 - 1, x = -1..1, y=-1..1, z=-1..1, XContours = [Automatic, 4], YContours = [Automatic, 11], ZContours = [Automatic, 21]), Axes = None, Scaling = Constrained)
Note that two of the lines are at the extremal values and therefore usually not visible.
Contour lines are drawn using the same settings for LineWidth and LineColor as parameter lines are. In the following example, we use a modified copy of a function object that only displays contour lines, but with settings different from the function object proper.
f := plot::Function3d(x^2 - 2*x*y - y^2, x = -2..2, y = -2..2): plot(f, plot::modify(f, ZContours = [Automatic, 15], LineWidth = 1, LineColor = RGB::Gray30.[0.8], XLinesVisible = FALSE, YLinesVisible = FALSE, Filled = FALSE))
By using a transformation that maps space into a plane, we can use this technique (by setting some more options) to display height-colored contour lines below a function plot:
f := plot::Function3d(8*sin(x-cos(y))+(x^2+x*y), x = -3..3, y = -3..3, Submesh=[2,2]): plot(f, plot::Transform3d([0, 0, -9], [1, 0, 0, 0, 1, 0, 0, 0, 0], plot::modify(f, ZContours = [Automatic, 15], LineWidth = 0.5, LineColorType = Dichromatic, LineColor = RGB::Red, LineColor2 = RGB::CornflowerBlue, XLinesVisible = FALSE, YLinesVisible = FALSE, Filled = FALSE)))