MathGroup Archive 2000

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Getting values from Plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg22737] Re: Getting values from Plot
  • From: bernd at bio.vu.nl (Bernd Brandt)
  • Date: Fri, 24 Mar 2000 03:27:24 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Dear All,

Thank you for your answers!

What i meant is to get the exact coordinates of the points used by Mathematica 
to plot the figure, in order to replot it in another plotting program
(GNUplot), which I find easier to use (setting labels, ticks etc).

The included answer from David Park was most easy, and not sensitive
to "PlotStyle". Also it is easy to get (x,y) pairs from different lines
in Plot.

Line 1:
Cases[p1[[1]], Line[_], Infinity] [[1, 1]]

Line 2:
Cases[p1[[1]], Line[_], Infinity] [[2, 1]]


Thanks!
Bernd
________________________________________________________________________________

p1 = Plot[x^2, {x, 0, 5}, PlotPoints -> 5];

The first part of p1 contains the graphics elements that make up the
curve or curves in the plot. Specifically, these will be Line graphics
primitives. In the above case there is only one Line, which we can pick
out with the Cases statement, and then extract the inner list of
points. The only reason I used Chop was to get a list short enough to
paste into the email. Otherwise I would have had to switch to InputForm
and copy out 16 place numbers.

plotpoints = Cases[p1[[1]], Line[_], Infinity][[1, 1]] // Chop[#, 10^-5] &

{{0, 0}, {0.0370328, 0.00137143}, {0.0707252, 0.00500206}, {0.109616,
    0.0120158}, {0.14638, 0.0214272}, {0.21177, 0.0448464}, {0.282748,
    0.0799462}, {0.360913, 0.130258}, {0.443778, 0.196939}, {0.592445,
    0.350991}, {0.745896, 0.556361}, {0.889651, 0.791479}, {1.21701,
    1.48111}, {1.55092, 2.40537}, {1.85643, 3.44634}, {2.54426,
    6.47328}, {3.1423, 9.87406}, {3.79509, 14.4027}, {5., 25.}}



  • Prev by Date: Re: newby plotting question
  • Next by Date: Re: Weird division
  • Previous by thread: Re: Getting values from Plot
  • Next by thread: CA