Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Getting the plotted data from a graph
Replies: 5   Last Post: Jun 17, 2013 6:18 AM

 Messages: [ Previous | Next ]
 Themis Matsoukas Posts: 322 From: Penn State Registered: 6/20/10
Re: Getting the plotted data from a graph
Posted: Jun 17, 2013 6:18 AM

> Dear All,
>
> My question is regarding the plotted data points in a
> graph. Assume you draw a graph of sinx as:
>
> g1 = Plot[Sin[x], {x, -Pi, Pi},
> Frame -> True, FrameLabel -> {"x", "y"},
> "y"}, ImageSize -> 2.6*72
> ]
>
> then how can I get all of the data points of this
> graph by using mathematica?
>
> This is really important for me and I couldn't find
>
>
> Best,
> Lily
>

If you do

FullForm[g1]

you will see that the data are nested inside Line[...] in the form of x-y pairs. Here is one way to get them out:

g1 = Plot[Sin[x], {x, -Pi, Pi}, Frame -> True,
FrameLabel -> {"x", "y"}, ImageSize -> 2.6*72]
data = Flatten[List @@ g1[[1, 1, 3, 2]], 1];
ListPlot[data]

Themis

Date Subject Author
6/16/13 Bob Hanlon
6/16/13 Tomas Garza Hernandez
6/16/13 W. Craig Carter
6/16/13 Louis Talman
6/17/13 Themis Matsoukas