({{, (RefLink[ContourPlot3D, paclet:ref/ContourPlot3D])[f,{x,(Subscript[x, min]),(Subscript[x, max])},{y,(Subscript[y, min]),(Subscript[y, max])},{z,(Subscript[z, min]),(Subscript[z, max])}]
produces a three-dimensional contour plot of f as a function of x, y, and z. }, {, (RefLink[ContourPlot3D, paclet:ref/ContourPlot3D])[f==g,{x,(Subscript[x, min]),(Subscript[x, max])},{y,(Subscript[y, min]),(Subscript[y, max])},{z,(Subscript[z, min]),(Subscript[z, max])}]
plots the contour surface for which f=g. }})

OpenersNotesSection(Spacer1)Details and Options

The contour surfaces plotted by (RefLink[ContourPlot3D, paclet:ref/ContourPlot3D]) can contain disconnected parts.

By default, (RefLink[ContourPlot3D, paclet:ref/ContourPlot3D]) shows each contour level as an opaque white surface, with normals pointing outward.

(RefLink[ContourPlot3D, paclet:ref/ContourPlot3D]) treats the variables x, y, and z as local, effectively using (RefLink[Block, paclet:ref/Block]).

(RefLink[ContourPlot3D, paclet:ref/ContourPlot3D]) has attribute (RefLink[HoldAll, paclet:ref/HoldAll]) and evaluates f and g only after assigning specific numerical values to x, y, and z.

In some cases, it may be more efficient to use (RefLink[Evaluate, paclet:ref/Evaluate]) to evaluate f and g symbolically before specific numerical values are assigned to x, y, and z.

Nothing is plotted in any regions where f evaluates to (RefLink[None, paclet:ref/None]).

(RefLink[ContourPlot3D, paclet:ref/ContourPlot3D]) has the same options as (RefLink[Graphics3D, paclet:ref/Graphics3D]), with the following additions and changes:

(RefLink[ContourPlot3D, paclet:ref/ContourPlot3D]) initially evaluates f at a 3D grid of equally spaced sample points specified by (RefLink[PlotPoints, paclet:ref/PlotPoints]). Then it uses an adaptive algorithm to subdivide at most (RefLink[MaxRecursion, paclet:ref/MaxRecursion]) times to generate smooth contours.

You should realize that since it uses only a finite number of sample points, it is possible for (RefLink[ContourPlot3D, paclet:ref/ContourPlot3D]) to miss features of your functions. To check your results, you should try increasing the settings for (RefLink[PlotPoints, paclet:ref/PlotPoints]) and (RefLink[MaxRecursion, paclet:ref/MaxRecursion]).

The arguments supplied to functions in (RefLink[MeshFunctions, paclet:ref/MeshFunctions]) and (RefLink[RegionFunction, paclet:ref/RegionFunction]) are x, y, z, f. Functions in (RefLink[ColorFunction, paclet:ref/ColorFunction]) and (RefLink[TextureCoordinateFunction, paclet:ref/TextureCoordinateFunction]) are by default supplied with scaled versions of these arguments.

(RefLink[ContourPlot3D, paclet:ref/ContourPlot3D]) returns (RefLink[Graphics3D, paclet:ref/Graphics3D])[(RefLink[GraphicsComplex, paclet:ref/GraphicsComplex])[data]].

Themes that affect 3D surfaces include:

OpenersPrimaryExamplesSection(Spacer1)Examples  (98)

OpenersExampleSection0(Spacer1)Basic Examples  (3)

Plot a 3D contour surface:

ContourPlot3D[x^3+y^2-z^2==0,{x,-2,2},{y,-2,2},{z,-2,2}]

Plot several contour surfaces:

ContourPlot3D[x^3+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2}]

Use styling to emphasize features:

ContourPlot3D[x^4+y^4+z^4-(x^2+y^2+z^2)^2+3(x^2+y^2+z^2)==3,{x, -2,2}, {y, -2, 2}, {z, -2, 2},Mesh->None,ContourStyle->Directive[Orange,Opacity[0.8],Specularity[White,30]]]

OpenersExampleSection1(Spacer1)Scope  (12)

OpenersExampleSubsection0(Spacer1)Sampling  (4)

More points are sampled where the function changes quickly:

ContourPlot3D[Sin[x y]==z,{x,0,2},{y,0,2},{z,-1,1},Mesh->All,MaxRecursion->1]

Areas where the function becomes nonreal are excluded:

ContourPlot3D[Sqrt[x y z],{x,-1,1},{y,-1,1},{z,-1,1}]

Use (RefLink[PlotPoints, paclet:ref/PlotPoints]) and (RefLink[MaxRecursion, paclet:ref/MaxRecursion]) to control adaptive sampling:

Grid[Table[ContourPlot3D[Sin[3x]Sin[3y]Sin[3z]==1/2,{x,0,3},{y,0,3},{z,-1,1},Mesh->None,BoxRatios->Automatic,PlotPoints->pp,MaxRecursion->mr],{mr,{0,1}},{pp,{5,10}}]]

Use (RefLink[RegionFunction, paclet:ref/RegionFunction]) to show interior features:

ContourPlot3D[x^2+y^2+z^2,{x,-2,2},{y,-2,2},{z,-2,2},Contours->5,RegionFunction->Function[{x,y,z},x<0||y>0],ContourStyle->{Red,Orange,Yellow,Green,Blue},Mesh->None]

OpenersExampleSubsection1(Spacer1)Presentation  (8)

Add labels:

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},AxesEdge->{{-1,-1},{1,-1},{-1,-1}},Ticks->None,Mesh->5,AxesLabel->{x,y,z},PlotLabel->x^2+y^2-z^2==1]

Color the surface by height:

ContourPlot3D[16x^3+16y^3-31z^3+24x^2z-48x^2y-48x y^2+24y^2z-93.5307z^2-72z==0,{x,-2,2},{y,-2,2},{z,-2.3,2},ColorFunction->Function[{x,y,z,f},ColorData["Rainbow"][z]],Mesh->4]

Apply styles to a contour:

ContourPlot3D[x^4+y^4+z^4-x^2-y^2-z^2+0.5==0,{x,-1,1},{y,-1,1},{z,-1,1},Mesh->None,PlotPoints->35,ContourStyle->Directive[Specularity[White, 50], Orange],Lighting->"Neutral"]

Show multiple implicit surfaces with explicit styles:

ContourPlot3D[{Abs[Sin[x]Sin[y]Sin[z]]==0.5,Abs[Cos[x]Cos[y]Cos[z]]==0.5},{x,0,3},{y,0,3},{z,0,3},ContourStyle->{Red,Blue},Mesh->None]

ContourPlot3D[x^2+y^2-z^2,{x,-3,3},{y,-3,3},{z,-3,3},Contours->{-3,0,3},ContourStyle->{Purple,Green,Cyan},Mesh->5,MeshStyle->GrayLevel[0.3],RegionFunction->Function[{x,y,z},x<0||y>0]]

Use transparency to show interior features:

ContourPlot3D[x^2+y^2+z^2,{x,-1,1},{y,-1,1},{z,-1,1},ContourStyle->Opacity[0.5],Mesh->None, ColorFunction->(Hue[#4/4]&)]

Use an overlay mesh:

ContourPlot3D[x^2-y^2==z,{x,-1,1},{y,-1,1},{z,-1,1},MeshFunctions->{#1-#2&,#1+#2&},MeshStyle->{Purple, Orange},Lighting->"Neutral",ContourStyle->Gray]

Fill with different colors between mesh lines:

ContourPlot3D[x^2-y^2==z,{x,-1,1},{y,-1,1},{z,-1,1},MeshFunctions->{#1-#2&,#1+#2&},MeshShading->{{Yellow,Blue},{Green,Cyan}}]

Use a theme with dark background in a high-contrast color scheme:

ContourPlot3D[x^2+y^2+z^2,{x,-1,1},{y,-1,1},{z,-1,1},PlotTheme->"Marketing"]

OpenersExampleSection2(Spacer1)Options  (66)

OpenersExampleSubsection2(Spacer1)BoundaryStyle  (3)

Use a red boundary around the edges of the contours:

ContourPlot3D[x^2+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2},BoundaryStyle->Red,Mesh->None]

Use (RefLink[None, paclet:ref/None]) to omit the boundary:

ContourPlot3D[x^2+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2},BoundaryStyle->None,Mesh->None]

(RefLink[BoundaryStyle, paclet:ref/BoundaryStyle]) applies to holes cut by (RefLink[RegionFunction, paclet:ref/RegionFunction]):

ContourPlot3D[x^2+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2}, BoundaryStyle->Red,Mesh->None,RegionFunction->Function[{x,y,z,w},x^2+y^2+z^2≤4]]

OpenersExampleSubsection3(Spacer1)BoxRatios  (1)

Use (RefLink[Automatic, paclet:ref/Automatic]) to show the natural scale of the surface:

ContourPlot3D[Sin[x y]==z,{x,-2,2},{y,-2,2},{z,-1,1}]

ContourPlot3D[Sin[x y]==z,{x,-2,2},{y,-2,2},{z,-1,1},BoxRatios->Automatic]

OpenersExampleSubsection4(Spacer1)ColorFunction  (5)

Color the contours according to the x, y, z, or f values:

Table[ContourPlot3D[x^2+y^2+z^2,{x,-2,2},{y,-2,2},{z,-2,2},ColorFunction->Function[{x,y,z,f},Evaluate[c]],PlotLabel->c,Axes->None],{c,{Hue[x],Hue[y],Hue[z],Hue[f]}}]

Use a named color gradient:

ContourPlot3D[x^2+y^2+z^2,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,Contours->4,ColorFunction->"DarkRainbow"]

(RefLink[ColorFunction, paclet:ref/ColorFunction]) has higher priority than (RefLink[ContourStyle, paclet:ref/ContourStyle]):

ContourPlot3D[x^2+y^2+z^2,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,Contours->4,ColorFunction->"DarkRainbow",ContourStyle->Directive[Opacity[0.5],Red]]

Use red when z<0:

ContourPlot3D[x^2+y^2+z^2,{x,-2,2},{y,-2,2},{z,-2,2},ColorFunction->Function[{x,y,z,f},If[z<0,Red,Green]],ColorFunctionScaling->False]

(RefLink[ColorFunction, paclet:ref/ColorFunction]) has lower priority than (RefLink[MeshShading, paclet:ref/MeshShading]):

ContourPlot3D[x^2+y^2+z^2,{x,-2,2},{y,-2,2},{z,-2,2},ColorFunction->Function[{x,y,z,f},Hue[z]],MeshFunctions->{#3&},MeshShading->{Automatic,Black}]

OpenersExampleSubsection5(Spacer1)ColorFunctionScaling  (2)

Use unscaled values to color the contours:

ContourPlot3D[x^2+y^2+z^2,{x,-1,1},{y,-1,1},{z,-1,1},Mesh->None,Contours->4,ColorFunction->Function[{x,y,z,f},Hue[f/5]],ColorFunctionScaling->False]

Use an overlay density based on the coordinate values:

ContourPlot3D[x^2+y^2==z^2,{x,-2,2},{y,-2,2},{z,-2,2},ColorFunction->Function[{x,y,z,f},Hue[Sin[x]Sin[y]]],ColorFunctionScaling->False,Mesh->None]

OpenersExampleSubsection6(Spacer1)Contours  (4)

Use 5 equally spaced contours:

ContourPlot3D[x^3+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2},Contours->5,Mesh->None]

Use automatic contour selection:

ContourPlot3D[x^3+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2},Contours->Automatic,Mesh->None]

Use specific contours:

ContourPlot3D[x^3+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2},Contours->{-2,2},Mesh->None]

Use specific contours with specific styles:

ContourPlot3D[x^3+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2},Contours->{{-2,Red},{2,Blue}},Mesh->None]

OpenersExampleSubsection7(Spacer1)ContourStyle  (8)

Use transparent contours:

ContourPlot3D[x^2+y^2+z^2,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,ContourStyle->Opacity[0.5]]

Use distinct colors for each contour:

ContourPlot3D[x^2+y^2+z^2,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,ContourStyle->{Red,Green,Blue}]

Use (RefLink[FaceForm, paclet:ref/FaceForm]) to get different colors on the inside and outside:

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->5,ContourStyle->{FaceForm[Yellow,Blue]}]

Alternate styles for contour surfaces:

ContourPlot3D[x^2+y^2+z^2,{x,-2,2},{y,-2,2},{z,-2,2},Contours->4,Mesh->None,ContourStyle->{Blue,Opacity[0.5]}]

Use the same style for all the equations:

ContourPlot3D[Evaluate[Table[x^2+y^2+z^2==i,{i,1,9,1.5}]],{x,0,2},{y,0,2},{z,0,2},Contours->6,Mesh->None,ContourStyle->Directive[Opacity[0.5],Orange]]

Use different styles for different equations:

ContourPlot3D[{x^2+y^2+z^2==2,x^2+y^2==z^2},{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,ContourStyle->{Red,Yellow}]

(RefLink[ColorFunction, paclet:ref/ColorFunction]) has higher priority than (RefLink[ContourStyle, paclet:ref/ContourStyle]):

ContourPlot3D[x^2+y^2+z^2==1,{x,-1,1},{y,-1,1},{z,-1,1},Mesh->None,ContourStyle->Directive[Opacity[0.5],Red],ColorFunction->Function[{x,y,z,f},Hue[z]]]

(RefLink[MeshShading, paclet:ref/MeshShading]) has higher priority than (RefLink[ContourStyle, paclet:ref/ContourStyle]):

ContourPlot3D[x^2+y^2+z^2==1,{x,-1,1},{y,-1,1},{z,-1,1},MeshFunctions->{#3&},ContourStyle->Directive[Opacity[0.5],Yellow],MeshShading->{Red,Automatic}]

OpenersExampleSubsection8(Spacer1)EvaluationMonitor  (2)

Show where (RefLink[ContourPlot3D, paclet:ref/ContourPlot3D]) samples a function:

ListPointPlot3D[Reap[ContourPlot3D[Sin[x y]==z,{x,-2,2},{y,-2,2},{z,-2,2},EvaluationMonitor:>Sow[{x,y,z}],PlotPoints->5]][[-1,1]],BoxRatios->Automatic,PlotStyle->PointSize[Tiny]]

Count how many times sin(x y)==z is evaluated:

Block[{k=0},ContourPlot3D[Sin[x y]==z,{x,-2,2},{y,-2,2},{z,-2,2},EvaluationMonitor:>k++];k]

OpenersExampleSubsection9(Spacer1)MaxRecursion  (1)

Refine the contour where it changes quickly:

Table[ContourPlot3D[Sin[x y]==z,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->All,MaxRecursion->r],{r,{0,1}}]

OpenersExampleSubsection10(Spacer1)Mesh  (6)

Show the initial and final sampling meshes:

{ContourPlot3D[Sin[x y]==z,{x,-2,2},{y,-2,2},{z,-1,1},Mesh->Full,MaxRecursion->1],ContourPlot3D[Sin[x y]==z,{x,-2,2},{y,-2,2},{z,-1,1},Mesh->All,MaxRecursion->1]}

Use (RefLink[None, paclet:ref/None]) to not draw any mesh:

ContourPlot3D[x^2+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None]

Use 5 mesh levels in each direction:

ContourPlot3D[x^2+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->5,MeshFunctions->{#1&,#2&,#3&}]

ContourPlot3D[x^2+y^2-z^2==0,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->5,MeshFunctions->{#1&,#2&,#3&}]

Use 5 mesh levels in the x direction and 10 in the y direction:

ContourPlot3D[x^2+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->{5,10},MeshFunctions->{#1&,#2&}]

ContourPlot3D[x^2+y^2-z^2==0,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->{5,10},MeshFunctions->{#1&,#2&}]

Use mesh lines at specific values:

ContourPlot3D[x^2+y^2-z^2==0,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->{{0},{0}},MeshFunctions->{#1&,#2&}]

Use different styles for different mesh lines:

ContourPlot3D[x^2+y^2-z^2==0,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->{{{0,Thick}},{{0,Red}}}]

OpenersExampleSubsection11(Spacer1)MeshFunctions  (2)

Use a mesh evenly spaced in the x, y, and z directions:

Table[ContourPlot3D[x^2+y^2+z^2==1,{x,-1,1},{y,-1,1},{z,-1,1},PlotLabel->f,MeshFunctions->{Function[{x,y,z},f]},Axes->None],{f,{x,y,z}}]

Mesh with respect to radial distance:

ContourPlot3D[x^3+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2},MeshFunctions->(Norm[{#1,#2,#3}]&)]

OpenersExampleSubsection12(Spacer1)MeshShading  (5)

Alternate red and blue sections in the z direction:

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},MeshFunctions->{#3&},MeshShading->{Red,Blue}]

(RefLink[MeshShading, paclet:ref/MeshShading]) has higher priority than (RefLink[ContourStyle, paclet:ref/ContourStyle]) for styling:

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},MeshFunctions->{#3&},MeshShading->{None,Blue}]

Use (RefLink[ContourStyle, paclet:ref/ContourStyle]) for some segments by setting (RefLink[MeshShading, paclet:ref/MeshShading]) to (RefLink[Automatic, paclet:ref/Automatic]):

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},MeshFunctions->{#3&},MeshShading->{Red,Automatic},ContourStyle->Directive[Opacity[0.5],Yellow]]

(RefLink[MeshShading, paclet:ref/MeshShading]) can be used with (RefLink[ColorFunction, paclet:ref/ColorFunction]):

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},MeshFunctions->{#3&},MeshShading->{Black,Automatic},ColorFunction->Function[{x,y,z,f},Hue[z]]]

Fill between regions defined by multiple mesh functions:

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},MeshShading->Table[RGBColor[r,g,b],{r,0,1,1/5},{g,0,1,1/5},{b,0,1,1/5}],Mesh->5,Lighting->"Neutral"]

OpenersExampleSubsection13(Spacer1)MeshStyle  (2)

Use a dashed mesh in the x direction:

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},MeshFunctions->{#1&},MeshStyle->Dashed,Mesh->5]

Use a dashed mesh in the x direction and a blue mesh in the y direction:

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->5,MeshFunctions->{#1&,#2&},MeshStyle->{Dashed,Blue}]

OpenersExampleSubsection14(Spacer1)NormalsFunction  (3)

Normals are automatically calculated:

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None]

Use (RefLink[None, paclet:ref/None]) to get flat shading for all the polygons:

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},NormalsFunction->None,Mesh->None]

Vary the effective normals used on the surface:

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,NormalsFunction->Function[{x,y,z,u,v},RandomReal[{-1,1},{3}]]]

OpenersExampleSubsection15(Spacer1)PerformanceGoal  (2)

Generate a higher-quality plot:

Timing[ContourPlot3D[Sin[x^2+y^2]==z,{x,-2,2},{y,-2,2},{z,-2,2},PerformanceGoal->"Quality"]]

Emphasize performance, possibly at the cost of quality:

Timing[ContourPlot3D[Sin[x^2+y^2]==z,{x,-2,2},{y,-2,2},{z,-2,2},PerformanceGoal->"Speed"]]

OpenersExampleSubsection16(Spacer1)PlotLegends  (3)

Use expressions as legends:

ContourPlot3D[{x^2+y^2-z^2==1,x^2+y^2+z^2==2},{x,-2,2},{y,-2,2},{z,-2,2},ContourStyle->{Yellow,Red},PlotLegends->"Expressions"]

Use (RefLink[Placed, paclet:ref/Placed]) to change legend placement:

ContourPlot3D[{x^2+y^2-z^2==1,x^2+y^2+z^2==2},{x,-2,2},{y,-2,2},{z,-2,2},ContourStyle->{Yellow,Red},PlotLegends->Placed["Expressions",Below]]

Use (RefLink[SwatchLegend, paclet:ref/SwatchLegend]) to modify the legend:

ContourPlot3D[{x^2+y^2-z^2==1,x^2+y^2+z^2==2},{x,-2,2},{y,-2,2},{z,-2,2},ContourStyle->{Yellow,Red},PlotLegends->SwatchLegend["Expressions",LegendFunction->"Frame"]]

OpenersExampleSubsection17(Spacer1)PlotPoints  (1)

Use more initial points to get a smoother contour:

Table[ContourPlot3D[Sin[x^2+y^2]==z,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None, MaxRecursion->0,PlotPoints->pp],{pp,{5,10,15,20}}]

OpenersExampleSubsection18(Spacer1)PlotRange  (2)

Show the contours over the (RefLink[Full, paclet:ref/Full]) x, y, z range:

ContourPlot3D[x^2+y^2+z^2==2,{x,-2,2},{y,-2,2},{z,-2,2}]

Automatically compute the x, y, z range:

ContourPlot3D[x^2+y^2+z^2==2,{x,-2,2},{y,-2,2},{z,-2,2},PlotRange->Automatic]

OpenersExampleSubsection19(Spacer1)PlotTheme  (4)

Use a theme with detailed grid lines, ticks, and legends:

ContourPlot3D[x^2+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2},PlotTheme->"Detailed"]

Turn off the grid lines:

ContourPlot3D[x^2+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2},PlotTheme->"Detailed",FaceGrids->None]

Use a theme with minimal styling:

ContourPlot3D[x^2+y^2+z^2,{x,-1,1},{y,-1,1},{z,-1,1},PlotTheme->"Minimal"]

Create a thick surface for 3D printing:

ContourPlot3D[x^4+y^4+z^4-(x^2+y^2+z^2)^2+3(x^2+y^2+z^2)==3,{x, -2,2}, {y, -2, 2}, {z, -2, 2},PlotTheme->"ThickSurface"]

OpenersExampleSubsection20(Spacer1)RegionFunction  (2)

Select a region in x, y, and z:

Table[ContourPlot3D[x^2+y^2+z^2,{x,-1,1},{y,-1,1},{z,-1,1},Mesh->None,Axes->None,Contours->4,RegionFunction->Function[{x,y,z},Evaluate[f]],PlotLabel->f],{f,{-1/2<x<1/2,-1/2<y<1/2,-1/2<z<1/2}}]

Remove a wedge to see hidden features:

ContourPlot3D[x^2+y^2+z^2,{x,-1,1},{y,-1,1},{z,-1,1},Contours->4,Mesh->None,Axes->None,RegionFunction->Function[{x,y,z},x<0||y>0]]

OpenersExampleSubsection21(Spacer1)TextureCoordinateFunction  (5)

Textures use scaled x and y coordinates by default:

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,Lighting->"Neutral",ContourStyle->Texture[ExampleData[{"ColorTexture","WavesPattern"}]]]

Use the x and z coordinates:

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,Lighting->"Neutral",TextureCoordinateFunction->({#1,#3}&),ContourStyle->Texture[ExampleData[{"ColorTexture","WavesPattern"}]]]

Use different textures for different surfaces:

ContourPlot3D[x^2+y^2-z^2,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,Lighting->"Neutral",ContourStyle->{Texture[ExampleData[{"ColorTexture","Ash"}]],Texture[ExampleData[{"ColorTexture","Amboyna"}]],Texture[ExampleData[{"ColorTexture","Laurel"}]]}]

Use unscaled coordinates:

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,Lighting->"Neutral",TextureCoordinateScaling->False,ContourStyle->Texture[ExampleData[{"ColorTexture","WavesPattern"}]]]

Use textures to highlight how parameters map onto a surface:

texture=ArrayPlot[{{1,1,1,2,1,1},{2,0,0,2,0,0},{2,0,0,2,0,0},{2,1,1,1,1,1},{2,0,0,2,0,0},{2,0,0,2,0,0}},ColorRules->{1->Red,2->Blue,0->White},Frame->False,PlotRangePadding->None,ImagePadding->None,ImageSize->100]

ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,Lighting->"Neutral",ContourStyle->Texture[texture]]

OpenersExampleSubsection22(Spacer1)TextureCoordinateScaling  (1)

Use scaled or unscaled coordinates for textures:

texture=ArrayPlot[{{1,1,1,2,1,1},{2,0,0,2,0,0},{2,0,0,2,0,0},{2,1,1,1,1,1},{2,0,0,2,0,0},{2,0,0,2,0,0}},ColorRules->{1->Red,2->Blue,0->White},Frame->False,PlotRangePadding->None,ImagePadding->None,ImageSize->100]

Table[ContourPlot3D[x^2+y^2-z^2==1,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,Lighting->"Neutral",ContourStyle->Texture[texture],TextureCoordinateScaling->s,PlotLabel->s],{s,{True,False}}]

OpenersExampleSubsection23(Spacer1)WorkingPrecision  (2)

Evaluate functions using machine-precision arithmetic:

ContourPlot3D[Sin[x y+10^16]==z,{x,-2,2},{y,-2,2},{z,-1,1}]

Evaluate functions using arbitrary-precision arithmetic:

ContourPlot3D[Sin[x y+10^16]==z,{x,-2,2},{y,-2,2},{z,-1,1},WorkingPrecision->20]

OpenersExampleSection3(Spacer1)Applications  (5)

Ellipsoidal surfaces (WebLink[[more info]:, http://mathworld.wolfram.com/Ellipsoid.html])

Table[ContourPlot3D[Evaluate[e],{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,AxesLabel->Automatic,Ticks->None,PlotLabel->e],{e,{(x/2)^2+y^2+z^2==1,x^2+(y/2)^2+z^2==1,x^2+y^2+(z/2)^2==1}}]

Compute their volumes:

Integrate[Boole[(x/2)^2+y^2+z^2≤1],{x,-2,2},{y,-2,2},{z,-2,2}]

NIntegrate[Boole[(x/2)^2+y^2+z^2≤1],{x,-2,2},{y,-2,2},{z,-2,2}]

Conic surfaces (WebLink[[more info]:, http://mathworld.wolfram.com/Cone.html])

Table[ContourPlot3D[Evaluate[e],{x,-2,2},{y,-2,2},{z,-2,2},Mesh->None,AxesLabel->Automatic,Ticks->None,PlotLabel->e],{e,{-x^2+y^2+z^2==0,x^2-y^2+z^2==0,x^2+y^2-z^2==0}}]

Show a sphere and hyperboloids of one and two sheets:

ContourPlot3D[{x^2+y^2-z^2==1,x^2+y^2+z^2==1,x^2+y^2-z^2==-1},{x,-2,2},{y,-2,2},{z,-2,2},BoxRatios->Automatic,RegionFunction->Function[{x,y,z},x<0||y>0],ContourStyle->{Yellow,Magenta,Cyan},Mesh->3]

Use (RefLink[Mesh, paclet:ref/Mesh]) to show that a hyperbolic paraboloid is a doubly ruled surface:

ContourPlot3D[x^2-y^2==z,{x,-1,1},{y,-1,1},{z,-1,1},MeshFunctions->{#1-#2&,#1+#2&},MeshStyle->{Purple, Orange},Lighting->"Neutral",ContourStyle->Gray]

An implicitly defined torus (WebLink[[more info]:, http://mathworld.wolfram.com/Torus.html])

torus[{R_, r_}, {x_,y_,z_}] :=((((x^2)+(y^2)+(z^2)+(R^2)-(r^2)))^2)==4(R^2)((x^2)+(z^2));

torus[{2,1},{x,y,z}]

ContourPlot3D[ Evaluate[torus[{3,1},{x,y,z}]],{x,-5,5},{y,-5,5},{z,-5,5},Mesh->None,ContourStyle->Directive[Orange,Specularity[White,20]],PlotPoints->25,PlotRange->Automatic,BoxRatios->Automatic]

An electrostatic potential built from a collection of point charges (Subscript[q, i]) at positions (Subscript[p, i]):

ElectroStaticPotential[q_,p_,r_] :=Sum[ ((q[[i]])/(Norm[r-p[[i]]])), {i,Length[q]}]

ElectroStaticPotential[{(Subscript[q, 1]),(Subscript[q, 2])},{{(Subscript[x, 1]),(Subscript[y, 1]),(Subscript[z, 1])},{(Subscript[x, 2]),(Subscript[y, 2]),(Subscript[z, 2])}},{x,y,z}]//TraditionalForm

Two charges (Subscript[q, 1])==1 and (Subscript[q, 2])==-1:

ContourPlot3D[Evaluate[ElectroStaticPotential[{1,-1},{{-1,0,0},{1,0,0}},{x,y,z}]],{x,-6,6},{y,0,4},{z,-4,4},Contours->{-0.75,-0.25,-0.1,0,0.1,0.25,0.75},  ContourStyle->Table[Hue[i/7],{i,0,6}],Mesh->None]

Two charges (Subscript[q, 1])==1 and (Subscript[q, 2])==-1:

ContourPlot3D[Evaluate[ElectroStaticPotential[{1,1},{{-1,0,0},{1,0,0}},{x,y,z}]],{x,-3,3}, {y,0,2},{z,-2,2},Contours ->{1,1.5,2},ContourStyle->Table[Hue[i/3],{i,0,2}],Mesh->None]

Three charges (Subscript[q, 1])==2, (Subscript[q, 2])==-1, and (Subscript[q, 3])==-1:

ContourPlot3D[Evaluate[ElectroStaticPotential[{2,-1,-1},{{0,0,0},{1,0,-1},{-1,0,-1}}, {x,y,z}]], {x,-4,4}, {y,0,4}, {z,-6,6},Contours -> {-0.75,-0.25,-0.1,0,0.1,0.25,0.75},ContourStyle->Table[Hue[i/7],{i,0,6}],Mesh->None ]

OpenersExampleSection4(Spacer1)Properties & Relations  (8)

(RefLink[ContourPlot3D, paclet:ref/ContourPlot3D]) samples more points where it needs to:

ContourPlot3D[Sin[x y]==z,{x,-2,2},{y,-2,2},{z,-2,2},Mesh->All,MaxRecursion->1]

Plotting an implicit surface is the same as finding the zero contour of a related function:

{ContourPlot3D[x^2+y^2-z^4,{x,-2,2},{y,-2,2},{z,-2,2},Contours->{0}],ContourPlot3D[x^2+y^2-z^4==0,{x,-2,2},{y,-2,2},{z,-2,2}]}

The orientation of the contours depends on the form of the input:

ContourPlot3D[x^2+y^2==z^4,{x,-1,1},{y,-1,1},{z,-1,1},Mesh->None,ContourStyle->FaceForm[Red,Yellow]]

ContourPlot3D[z^4==x^2+y^2,{x,-1,1},{y,-1,1},{z,-1,1},Mesh->None,ContourStyle->FaceForm[Red,Yellow]]

Use (RefLink[ListContourPlot3D, paclet:ref/ListContourPlot3D]) for plotting data:

data=Flatten[Table[{x,y,z,Sin[x y]-z},{x,-2,2,0.2},{y,-2,2,0.2},{z,-2,2,0.2}],2];

ListContourPlot3D[data]

Use (RefLink[RegionPlot3D, paclet:ref/RegionPlot3D]) for implicit regions in three dimensions:

RegionPlot3D[Sin[x y]≥z,{x,-2,2},{y,-2,2},{z,-2,2}]

Use (RefLink[Plot3D, paclet:ref/Plot3D]) for surfaces:

Plot3D[Sin[x y],{x,-2,2},{y,-2,2}]

Use (RefLink[ParametricPlot3D, paclet:ref/ParametricPlot3D]) for parametric curves and regions in three dimensions:

{ParametricPlot3D[{Cos[u],Sin[u],u/(6Pi)},{u,0,6Pi}],ParametricPlot3D[{u+v,u-v,u^2-v^2},{u,-2,2},{v,-2,2}]}

Use (RefLink[ContourPlot, paclet:ref/ContourPlot]) and (RefLink[DensityPlot, paclet:ref/DensityPlot]) for contours and densities in two dimensions:

{ContourPlot[Sin[x y],{x,-2,2},{y,-2,2}],
DensityPlot[Sin[x y],{x,-2,2},{y,-2,2}]}

OpenersExampleSection5(Spacer1)Possible Issues  (3)

Use increased settings for (RefLink[PlotPoints, paclet:ref/PlotPoints]) or (RefLink[MaxRecursion, paclet:ref/MaxRecursion]) to capture features of a surface:

ContourPlot3D[z^2+x z==x^2z,{x,-0.5,1.5},{y,-1,1},{z,-1,1},Mesh->None]

ContourPlot3D[z^2+x z==x^2z,{x,-0.5,1.5},{y,-1,1},{z,-1,1},Mesh->None,MaxRecursion->4]

Use more initial points to capture more components of the contour surface:

ContourPlot3D[Sin[3x]Sin[3y]Sin[3z]==1/2,{x,0,3},{y,0,3},{z,-1,1},Mesh->None,BoxRatios->Automatic,PlotPoints->5]

ContourPlot3D[Sin[3x]Sin[3y]Sin[3z]==1/2,{x,0,3},{y,0,3},{z,-1,1},Mesh->None,BoxRatios->Automatic,PlotPoints->10]

For functions that are always non-negative, it is not possible to find the 0 contour:

ContourPlot3D[(x^2+y^2+z^2-1)^2==0,{x,-1,1},{y,-1,1},{z,-1,1}]

OpenersExampleSection6(Spacer1)Neat Examples  (1)

A transcendental periodic implicit surface:

ContourPlot3D[ Cos[x]Sin[y]+Cos[y]Sin[z]+Cos[z]Sin[x]==0,{x,-2π,2π}, {y,-2π,2π},{z,-2π,2π},ContourStyle->Directive[FaceForm[Orange,Red],Specularity[White,30]],Mesh->None]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[SliceContourPlot3D, paclet:ref/SliceContourPlot3D])  ▪  (RefLink[ListContourPlot3D, paclet:ref/ListContourPlot3D])  ▪  (RefLink[RegionPlot3D, paclet:ref/RegionPlot3D])  ▪  (RefLink[ParametricPlot3D, paclet:ref/ParametricPlot3D])  ▪  (RefLink[VectorPlot3D, paclet:ref/VectorPlot3D])  ▪  (RefLink[ContourPlot, paclet:ref/ContourPlot])  ▪  (RefLink[MeshFunctions, paclet:ref/MeshFunctions])  ▪  (RefLink[ContourLabels, paclet:ref/ContourLabels])  ▪  (RefLink[ContourShading, paclet:ref/ContourShading])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Function Visualization, paclet:guide/FunctionVisualization])}, {▪(RefLinkPlain[3D Printing, paclet:guide/3DPrinting])}})}})