Debra Woods

Contour Plots, and where they come from

Brief Description:

This program demonstrates how a contour plot of a three dimensional surface is created and what it represents.

Initialization cell

Needs["Graphics`Colors`"]
Off[ParametricPlot3D::ppcom]

This program is a demonstration of how a contour plot of a three dimensional surface is created, and what it represents.  Let us first consider the paraboloid f(x,y) = 2 x€ + 2 y€ as our three dimensional surface.  The following code will show the plot.

(**  Create three dimensional axes  **)

spacer = 0.2;
h = 5;
threedims = 
      Graphics3D[{
            {Line[{{-h,0,0},{h,0,0}}]},
                    Text["x",{h + spacer,0,0}],
            {Line[{{0,-h,0},{0,h,0}}]},
                    Text["y",{0, h + spacer,0}],
            {Line[{{0,0,-h},{0,0,h}}]},
                    Text["z",{0,0,h + spacer}]}];

(**  Create three dimensional surface  **)

parab =
ParametricPlot3D[{ Sqrt[2 u] Cos[t]
						, Sqrt[2 u] Sin[t],u},
					{t,0,2 Pi},{u,0,4},
			    	ViewPoint->{1.75,.5,1.7},
					AspectRatio->Automatic
					,AmbientLight->GrayLevel[1.0],
					LightSources->{}];

If we ask Mathematica for a contour plot of this surface we get:

ContourPlot[2 x^2 + 2 y^2,{x,-4,4},{y,-4,4},
		ContourShading->False,Axes->True];

Notice that these particular level curves appear to be concentric circles.  Let's see if we can now demonstrate where this comes from.  The following creates the surface and some level curves on the surface parallel to the xy-plane.  The animation will show the level curves falling off the surface and on to the xy-plane.

(**  set contours  **)

circfunc[u_,t_,z_] = {Sqrt[2 u] Cos[t],Sqrt[2 u] Sin[t],z};

circs2[u_,z_] := ParametricPlot3D[Append[
			circfunc[u,t,z],
				{Purple,Thickness[0.01]}],
					{t,0,2 Pi},
			    	ViewPoint->{1.75,.5,1.7},
					AspectRatio->Automatic
					,DisplayFunction->Identity];	

Clear[jj];

Table[
	Show[threedims,parab,circs2[1,jj],circs2[2,2],circs2[3,3],
		Boxed->False,Axes->False,
		ViewPoint->{2.570, 2.413, 0.730},
		AmbientLight->GrayLevel[1.0],
					LightSources->{},
					PlotRange->{{-3,3},{-3,3},{0,9}},
					DisplayFunction->$DisplayFunction]
					,{jj,1,0,-1}];

Clear[jj];

Table[
	Show[threedims,parab,circs2[1,0],circs2[2,jj],circs2[3,3],
		Boxed->False,Axes->False,
		ViewPoint->{2.570, 2.413, 0.730},
		AmbientLight->GrayLevel[1.0],
					LightSources->{},
					PlotRange->{{-3,3},{-3,3},{0,9}},
					DisplayFunction->$DisplayFunction]
					,{jj,2,0,-1}];

Clear[jj];

Table[
	Show[threedims,parab,circs2[1,0],circs2[2,0],circs2[3,jj],
		Boxed->False,Axes->False,
		ViewPoint->{2.570, 2.413, 0.730},
		PlotRange->{{-3,3},{-3,3},{0,9}},
		AmbientLight->GrayLevel[1.0],
					LightSources->{},
					DisplayFunction->$DisplayFunction]
					,{jj,3,0,-1}];

Select the above graphics and press command-y to animate.

What you can see from this is when the level curves fall off of the paraboloid, the land on the xy-plane and form the concentric circles which in turn creates the contour plot.

For future projects, I plan to include more interesting surfaces and possibly try to generalize the program to solve for as many possible surfaces as it can.