MathGroup Archive 1996

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

Search the Archive

Re: how to draw the contour lines on a surface

  • To: mathgroup at
  • Subject: [mg3931] Re: how to draw the contour lines on a surface
  • From: ianc (Ian Collier)
  • Date: Fri, 10 May 1996 03:29:55 -0400
  • Organization: Wolfram Research, Inc.
  • Sender: owner-wri-mathgroup at

In article <4m7q96$k5h at>, goffinet
<goffinet at> wrote:

>     Hello
>     I'm sure the answer lies somewhere inthe Mathematica journal, but I 
> have been unable to find it
>      I want to get an image of a surface (with z=z(x,y) would be a good 
> start, with an implicit surface it would be even better) with the lines 
> z=Constant drawn on it. I don't want to Solve différential equations or 
> such, merely to make use of what is already done in ContourPlot (or 
> ImplicitPlot) and to draw the lines on the surface
>      How can one get the Lines[... , ... ,   ] which are used by the 
> final display of a ContourPlot? 

Tom Wickham-Jones describes several methods for forming contour
lines in 3 dimensions in his book "Mathematica Graphics: Techniques 
& Applications" (TELOS/Springer Verlag 1994).

This example, taken from pages 276-277 of that book, illustrates 
one method.

First we define a function and create contour and surface plots of it.

    fun[x_, y_ ] := x y

    c = ContourPlot[ fun[x, y], {x, -2,2},{y,-2,2},
            ContourShading -> False]

    s = Show[ SurfaceGraphics[c]]

Now it is converted to a Graphics object. The lines are converted to
three-dimensional lines by taking each point and appending the value 
of the function at that point.

    c3d = First[ Graphics[c]] /.
            Line[pts_] :>
                (val = Apply[fun, First[pts]];
                Line[Map[Append[#, val]&, pts]]);


Finally we show the lines together with the surface.

    Show[s, %]

There are a number of ways that this could be enhanced. For a more 
detailed discussion I would strongly recommend that you take a look 
at Tom Wickham-Jones' book.

I hope this helps.


Ian Collier
Wolfram Research, Inc.
tel:(217) 398-0700   fax:(217) 398-0747    ianc at
Wolfram Research Home Page:


  • Prev by Date: ShowGraph point size
  • Next by Date: Re: Q: Documenting packages: TeX-style available
  • Previous by thread: Re: how to draw the contour lines on a surface
  • Next by thread: Re: how to draw the contour lines on a surface