Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #14885 > unrolled thread
| Started by | "Lily T." <econactually@gmail.com> |
|---|---|
| First post | 2013-06-15 08:17 +0000 |
| Last post | 2013-06-16 09:11 +0000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.soft-sys.math.mathematica
Getting the plotted data from a graph "Lily T." <econactually@gmail.com> - 2013-06-15 08:17 +0000
Re: Getting the plotted data from a graph psycho_dad <s.nesseris@gmail.com> - 2013-06-16 09:11 +0000
| From | "Lily T." <econactually@gmail.com> |
|---|---|
| Date | 2013-06-15 08:17 +0000 |
| Subject | Getting the plotted data from a graph |
| Message-ID | <kph7uu$2f4$1@smc.vnet.net> |
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"}, 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 the answer anywhere online!
Thank you for your help in advance!
Best,
Lily
[toc] | [next] | [standalone]
| From | psycho_dad <s.nesseris@gmail.com> |
|---|---|
| Date | 2013-06-16 09:11 +0000 |
| Message-ID | <kpjvfp$9n0$1@smc.vnet.net> |
| In reply to | #14885 |
Hi Lily,
That's simple after you realize that even a Plot is a list {{},{},...}. For example, in your case writing g1[[1]] will give you a list of all the elements in the plot. So, then the question is how do you retrieve the data from that mess?
Simple! Do you see the Line[], which obviously makes the line in your plot? Just extract by specifying the appropriate levels, ie g1[[1, 1, 3, 2, 1]]. Then, you can plot the points with ListPlot[g1[[1, 1, 3, 2, 1]]] to make sure it is indeed what you want.
Finally, after one realizes this, you can easily do some cool things, eg writing
g1 /. Hue[x_, y_, z_] -> Red
will change the color *after* you made the plot! So, if you have a plot that takes a long time to make, you can still make changes afterwards ;-)
Cheers
[toc] | [prev] | [standalone]
Back to top | Article view | comp.soft-sys.math.mathematica
csiph-web