Re: Getting values from Plot
- To: mathgroup at smc.vnet.net
- Subject: [mg22666] Re: Getting values from Plot
- From: "Kevin J. McCann" <kevin.mccann at jhuapl.edu>
- Date: Sat, 18 Mar 2000 01:27:43 -0500 (EST)
- Organization: Johns Hopkins University Applied Physics Lab, Laurel, MD, USA
- References: <8aqqt7$a4o@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Note that the actual part of the plot p1[[1,3,1,1]] below depends on the
options used in the plot. If you just go with a barebones plot use
p1[[1,1,1,1]] instead. Should have looked before I posted.
Kevin
First post:
There may be other ways, but here is one. The trick is to remember that
everything is a Mathematica expression, e.g.
p1 = Plot[Sin[x], {x, 0, 2*Pi}];
Generates a plot, now to look at the Mathematica expression type
p1//FullForm
and you will see more than you probably wanted, but you may recognize some
things in there. Now try
p1[[1]]
You will see a few Graphics directives and Line[{lots of points}]. This is
what you want. To make this story short type
pts = p1[[1,3,1,1]]
and you will have a list of the points that Mathematica used to generate the plot.
You can show them with:
ListPlot[pts, PlotJoined -> False];