[mg90391] Extracting points from a contour plot

View: New views
2 Messages — Rating Filter:   Alert me  

[mg90391] Extracting points from a contour plot

by ajfriend :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I'm not a Mathematica expert, so hopefully this isn't too stupid of a
question:

I'm using ContourPlot to plot the curve of zeros of a function of two
variables within a range of vales (0 < x < 1, 0 < y < 1). Now, what I
really want is the list of points that it generates. I've tried
playing with Solve and NSolve, but these are either not working or are
taking too long. What is the easiest way of getting at the list of
points that ContourPlot has generated? Do I have to do something like
InputForm[%] and then cut and paste the list that I want, or is there
some easier way of doing it?

Or, maybe there is a way of getting the points that I want without
using ContourPlot that I haven't come across yet, or maybe I'm just
not using Solve correctly.

Any help would be great.

Thanks,
AJ


[mg90409] Re: [mg90391] Extracting points from a contour plot

by W_Craig Carter :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello AJ,
Instead of giving a single command, these steps to extract what you
want may be instructive:
cp = ContourPlot[Cos[x] + Cos[y] == 1/2, {x, 0, 4 Pi}, {y, 0, 4 Pi}]

cp // FullForm

p = Position[cp, _Line]

lines = Extract[cp, p]

verts = lines /. Line[a__] :> a

points = Extract[cp, Position[cp, _GraphicsComplex]][[1, 1]]

points is a list {{x1,y1},{x2,y2}... and lines is a list of
connections between those vertices {{index1,index4,index6..},{...}}
(see GraphicsComplex)

Good luck, WCC

On Tue, Jul 8, 2008 at 2:26 AM,  <ajfriend@...> wrote:

> I'm not a Mathematica expert, so hopefully this isn't too stupid of a
> question:
>
> I'm using ContourPlot to plot the curve of zeros of a function of two
> variables within a range of vales (0 < x < 1, 0 < y < 1). Now, what I
> really want is the list of points that it generates. I've tried
> playing with Solve and NSolve, but these are either not working or are
> taking too long. What is the easiest way of getting at the list of
> points that ContourPlot has generated? Do I have to do something like
> InputForm[%] and then cut and paste the list that I want, or is there
> some easier way of doing it?
>
> Or, maybe there is a way of getting the points that I want without
> using ContourPlot that I haven't come across yet, or maybe I'm just
> not using Solve correctly.
>
> Any help would be great.
>
> Thanks,
> AJ
>
>



--
W. Craig Carter

LightInTheBox - Buy quality products at wholesale price