Re: Re: Getting values from a Plot
- To: mathgroup at smc.vnet.net
- Subject: [mg7495] Re: [mg7483] Re: Getting values from a Plot
- From: Allan Hayes <hay at haystack.demon.co.k>
- Date: Sat, 7 Jun 1997 03:48:14 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
There can be problems with using
Plot[....][[1,1,1,1]]
to get the list of coordinates when the plot is in two parts (eg.
Sqrt[x^2-1]), which we may not detect in advance, or when PlotStyle
has been used.
The alternative
Cases[Plot[....], Line[x]->x, Infinity]
deals with these.
Of course it will pick up all lines, for example, any from Epilog
and Prolog - these could be excluded by
Cases[Plot[....][[1]], Line[x]->x, Infinity]
(1) the plot may be in two parts.
pl = Plot[Sqrt[x^2-1],{x,-2,2}]
pl[[1,1]]
{Line[{{-2.,1.73205},...,{-1.00082,
0.0404806}}],
Line[{{1.00166,0.057683},...,{2.,1.73205}}]
}
We get the coordinates of only the first one
pl[[1,1,1,1]]
{{-2.,1.},{-1.83773,0.915277},... ,{-1.00082,0.0286183}}
(2) We may have used PlotStyle
pl2 =Plot[Sin[x],{x,-1,1},PlotStyle->Hue[0]]
pl2[[1]]
{Hue[0],{Line[{{-1.,-0.841471},...,{1.,0.841471}}]}}
Allan Hayes
hay at haystack.demon.co.uk
http://www.haystack.demon.co.uk/training/html
voice:+44 (0)116 2714198
fax: +44 (0)116 2718642
12 Copse Close, Leicester, LE2 4FB, UK