MathGroup Archive 1998

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

Search the Archive

Re: Extract a contour from a 3-D plot.



Chris Farr wrote:
> 
> I would like to extract a contour from a 3-D plot.
> 
> I am particularly interested in the contour associated with a value of =
> zero.  That is, the curve generated when I set the option in
> ContourPlot = to Contours->{0}.
> 
> How can I extract this contour ( I guess the contour would be a =
> collection of XY coordinates) ?  What if there are two contours with a
> = value of zero?  How can I extract both of them?  Thanks in advance.
> 

If you intend to use ContourPlot then the first problem is that it
generates a ContourGraphics object which store a matrix of heights,
from which the contour lines are constructed for display - not the
lines themselves. However, we can convert the ContourGraphics object to
a Graphics object which does contain the lines and them use Cases to
extract the lines - all of them:


In[180]:=
ContourPlot[x^2-y^2-1 ,{x,-3,3},{y,-3,3}, Contours ->{0},
ContourShading-> False]

Out[180]=
-ContourGraphics-

In[181]:=
Cases[Graphics[%],Line[_], Infinity]

Out[181]=
{Line[{{-3., 2.82655}, ..., {-3., -2.82655}}],  Line[{{3., 2.82655},
...,  {3., -2.82655}}]}

Now you can do what you want with the lists of points on the lines.


Allan Hayes
Training and Consulting
Leicester, UK
hay@haystack.demon.co.uk
http://www.haystack.demon.co.uk
voice: +44 (0)116 271 4198
fax: +44 (0)116 271 8642




  • Prev by Date: Re: [Q] how to use simple notation to combine many graphics
  • Next by Date: Re: In-reply-to: <199803040639.BAA09722@smc.vnet.net.>
  • Prev by thread: Re: Extract a contour from a 3-D plot.
  • Next by thread: Re: Extract a contour from a 3-D plot.