MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: [Q] CountorPlot as part of 3D Plot

  • To: mathgroup at
  • Subject: [mg4398] Re: [Q] CountorPlot as part of 3D Plot
  • From: Xah Lee <xah at>
  • Date: Mon, 15 Jul 1996 11:13:37 -0400
  • Organization: Best Internet Communications
  • Sender: owner-wri-mathgroup at

Gerd Lanfermann wrote:
> problem: i want to display a 3d plot, of lets say saddle, using Plot3D.
> I also want to to include a colored contour plot of this saddle  ON THE
> BOTTOM of the 3D-box, that matches the 3d plot.

The plan is to convert your ContourGraphics to a 3D graphics primitive, then you can display 
it with the surface of your function.

The data of ContourGraphics, DensityGraphics, and  SurfaceGraphics are just a rectangular 
array. The difference is how they are rendered in Show. To display a ContourGraphics as a 
surface, just add the head SurfaceGraphics to your data and use Show. But what you want is to 
convert the contour data array into graphic primitives as a list of Lines and Polygons that 
represents the contour. This you do by adding the head Graphics to it. Once your contour data 
array became a list of 2D graphic primitives, you add a dimension to all the point in them so 
they became a list of 3D primitives. Finally display this together with your SurfaceGraphics 
of the function.

myFunction[a_,b_][x_,y_]:=((x-a)^2 + y^2) ((x+a)^2 + y^2) - b^4

myContourData = ContourPlot[ myFunction[1,1][x,y],
	{x,-2,2}, {y,-1.2,1.2},
	Contours->Table[ i^2-1,{i,-1, 2.5, 1/4}],
	ContourLines->True, ContourShading->True,
	Ticks->{Range[-1,1], Range[-2,2],{-.5,.5}}

myContourGP = First@ Graphics@ myContourData;
myContourGP = N@ myContourGP /. {x_?AtomQ, y_?AtomQ}->{x,y,-20};

	{ SurfaceGraphics@ myContourData,
	Graphics3D@ myContourGP

Hope this helps.

If you are using a Mac, you might want to get Rotater--An excellent freeware for visualing 
wireframes in realtime, together with a mathematica to Rotater converter package. You can get 
them at

 xah at; 74631.731 at
 Mountain View, CA, USA


  • Prev by Date: Re: Abort options in Windows
  • Next by Date: Re: c code generation
  • Previous by thread: Re: [Q] CountorPlot as part of 3D Plot
  • Next by thread: Re: [Q] CountorPlot as part of 3D Plot