This is documentation for Mathematica 3, which was
based on an earlier version of the Wolfram Language.
View current documentation (Version 11.2)
 Documentation / Mathematica / Add-ons / Standard Packages / Graphics  /

Graphics`ContourPlot3D`

You can create standard two-dimensional contour plots using the built-in functions ContourPlot and ListContourPlot. ContourPlot3D is the three-dimensional analog of ContourPlot. ContourPlot[f,

x,xmin,xmax

,

y,ymin,ymax

] will plot lines showing particular values of as a function of and . Similarly, ContourPlot3D[

f,

x,xmin,xmax

,

y,ymin,ymax

,

z,zmin,zmax

] will plot surfaces showing particular values of as a function of , , and . ContourPlot3D works by dividing the three-dimensional space into cubes and deciding if the surface intersects each cube. If the surface does intersect a cube, ContourPlot3D

will subdivide this cube further, and so on.


Making three-dimensional contour plots.

  • This loads the package.
  • In[1]:= <<Graphics`ContourPlot3D`

  • This produces a three-dimensional plot of the zero values of the function.
  • In[2]:= ContourPlot3D[Cos[Sqrt[ x^2 + y^2 + z^2 ]],
    {x,-2,2}, {y,0,2}, {z,-2,2}]



    Options for ContourPlot3D.

    Each value specified in Contours generates a different surface. ContourStyle colors each surface. To use this option, you must set Lighting->False. MaxRecursion sets the number of times you subdivide each cube. However, if the surface does not intersect the cube, the cube is not subdivided. With MaxRecursion->0 the plot points are chosen from PlotPoints->x or PlotPoints->

    x,y,z. If MaxRecursion is greater than , recursion takes place. You can give a different number of plot points for the first and subsequent divisions of a cube. PlotPoints

    ->



    ,

    means that plot points are used first, and then if you subdivide, plot points are used. PlotPoints

    ->





    ,



    ,



    ,



    ,



    ,



    is also valid. ContourPlot3D and ListContourPlot3D return a Graphics3D object. This means the functions will accept any option that can be specified for a Graphics3D

    object.

  • Here is another plot showing a contour value of

    .
  • In[3]:= ContourPlot3D[x y z,
    {x,-1,1}, {y,-1,1}, {z,-1,1},
    Contours -> {.1}]



    Options for ListContourPlot3D.

    ListContourPlot3D takes a three-dimensional data set interpreted as a representation of a function , where the ranges of x, y, and z are set by the MeshRange option. With the default value of Automatic for MeshRange, the ranges of x, y, and z

    are specified by the dimensions of the data set.

  • This defines a three-dimensional array of data.
  • In[4]:= data = Table[x^2 + 2*y^2 + 3*z^2,
    {z, -1, 1, .25},
    {y, -1, 1, .25},
    {x, -1, 1, .25}];

  • Here is a plot of the contours and

    specified by green and red contour surfaces, respectively.
  • In[5]:= ListContourPlot3D[data,
    MeshRange -> {{-1,1}, {-1,1}, {-1,1}},
    Contours -> {1.5, 3.},
    Lighting -> False, Axes -> True,
    ContourStyle -> {{RGBColor[0,1,0]},
    {RGBColor[1,0,0]}}]