# Get discrete data points from ListLinePlot or Interpolation

If I have the following data:

data={{52.144,-0.415856},{52.311,-0.411763},{52.477,-0.407533},{52.644,-0.403428},{52.81,-0.398448},{52.977,-0.392951},{53.143,-0.387239},{53.31,-0.38116},{53.476,-0.374848},{53.643,-0.368583},{53.81,-0.362312},{53.976,-0.355892},{54.143,-0.348895},{54.309,-0.340285},{54.476,-0.330162},{54.642,-0.319722},{54.808,-0.308724},{54.975,-0.297659},{55.141,-0.286469},{55.308,-0.274846},{55.474,-0.260542},{55.641,-0.245385},{55.807,-0.229959},{55.973,-0.214269},{56.14,-0.192554},{56.306,-0.170888},{56.472,-0.148772},{56.638,-0.12581},{56.805,-0.0995351},{56.971,-0.0722411},{57.137,-0.0432011},{57.303,-0.0130451},{57.469,0.0207889},{57.635,0.0560209},{57.801,0.0919189},{57.967,0.128273},{58.133,0.167789},{58.299,0.206891},{58.465,0.245897},{58.631,0.285173},{58.797,0.322127},{58.963,0.355769},{59.129,0.386705},{59.295,0.414137},{59.462,0.432324},{59.628,0.444006},{59.795,0.448333},{59.961,0.448087},{60.128,0.435572},{60.295,0.416547},{60.462,0.389938},{60.629,0.360539},{60.797,0.326809},{60.964,0.291986},{61.131,0.256455},{61.298,0.220636},{61.465,0.187565},{61.633,0.156139},{61.8,0.126938},{61.967,0.099093},{62.134,0.0811721},{62.301,0.0650991},{62.467,0.0513651},{62.634,0.0388921},{62.801,0.0296651},{62.968,0.0238881},{63.134,0.0196881},{63.301,0.0160351},{63.468,0.0132581},{63.634,0.0106001},{63.801,0.00836313},{63.968,0.00612014},{64.134,0.00429014},{64.301,0.00261115},{64.468,0.00184416},{64.634,0.00173016},{64.801,0.00213317},{64.968,0.00214618},{65.134,0.00227218},{65.301,0.00245319},{65.467,0.00257919},{65.634,0.0027782},{65.801,0.00309121},{65.967,0.00343921},{66.134,0.00411222},{66.301,0.00467123},{66.467,0.00522923},{66.634,0.00581224},{66.8,0.00679024},{66.967,0.00754725},{67.134,0.00813626},{67.3,0.00872426},{67.467,0.00950527},{67.633,0.0104293},{67.8,0.0114803},{67.967,0.0126153},{68.133,0.0144153},{68.3,0.0160483},{68.466,0.0182503},{68.633,0.0209573},{68.8,0.0242403},{68.966,0.0272583},{69.133,0.0304213},{69.299,0.0340453},{69.466,0.0386423},{69.632,0.0432443},{69.799,0.0481233},{69.965,0.0533073},{70.132,0.0595904},{70.298,0.0658004},{70.465,0.0723354},{70.631,0.0797334},{70.798,0.0886744},{70.964,0.0992044},{71.131,0.111229},{71.297,0.123523},{71.464,0.13943},{71.63,0.157964},{71.796,0.180194},{71.962,0.204914},{72.128,0.234872},{72.294,0.26963},{72.46,0.308324},{72.626,0.347756},{72.792,0.36641},{72.959,0.356781},{73.127,0.316349},{73.294,0.259128},{73.462,0.19835},{73.629,0.149427},{73.797,0.111857},{73.964,0.0823745},{74.131,0.0661275},{74.298,0.0518725},{74.465,0.0423335},{74.631,0.0347195},{74.798,0.0287745},{74.965,0.0231776},{75.131,0.0195835},{75.298,0.0173646},{75.465,0.0164716},{75.631,0.0149476},{75.798,0.0132266},{75.965,0.0115416},{76.131,0.00978359},{76.298,0.0080326},{76.465,0.00636561},{76.631,0.00478761},{76.798,0.00346862},{76.965,0.00215563},{77.131,0.000889631},{77.298,-0.000297358},{77.465,-0.000848347},{77.631,-0.00152635},{77.798,-0.00222134},{77.964,-0.00287534},{78.131,-0.00302433},{78.298,-0.00319132},{78.464,-0.00328132},{78.631,-0.00332831},{78.798,-0.0029853},{78.964,-0.0027753},{79.131,-0.00255229},{79.297,-0.00230629},{79.464,-0.00180728},{79.631,-0.00117627},{79.797,-0.000498269},{79.964,0.000516742},{80.13,0.00251474},{80.297,0.00448375},{80.464,0.00719076},{80.63,0.00992676},{80.797,0.0125498},{80.963,0.0149918},{81.13,0.0173568},{81.296,0.0193608},{81.463,0.0207598},{81.63,0.0217508},{81.796,0.0212228},{81.963,0.0196878},{82.13,0.0187708},{82.296,0.0182308},{82.463,0.0177578},{82.63,0.0173628},{82.796,0.0177348},{82.963,0.0179819},{83.129,0.0181919},{83.296,0.0186189},{83.463,0.0206239},{83.629,0.0229579},{83.796,0.0261029},{83.962,0.0299249},{84.129,0.0336699},{84.295,0.0371859},{84.462,0.0407749},{84.628,0.0443869},{84.795,0.0479879},{84.962,0.0516489},{85.128,0.0554169},{85.295,0.0592339},{85.461,0.0633919},{85.628,0.0676229},{85.794,0.0720389},{85.961,0.0767019},{86.127,0.0818439},{86.294,0.087233},{86.46,0.092891},{86.627,0.098496},{86.793,0.106128},{86.96,0.114025},{87.126,0.122695},{87.293,0.131708},{87.459,0.143894},{87.626,0.157887},{87.792,0.175509},{87.958,0.197589},{88.124,0.238485},{88.289,0.29906},{88.454,0.405439},{88.617,0.563578},{88.779,0.847848},{88.946,0.827773},{89.116,0.613655},{89.287,0.387232},{89.456,0.256375},{89.625,0.164842},{89.793,0.103782},{89.96,0.0587831},{90.127,0.0359241},{90.294,0.0188071},{90.461,0.00694613},{90.628,-0.00268286},{90.795,-0.00732585},{90.961,-0.0106678},{91.128,-0.0125208},{91.295,-0.0139958},{91.461,-0.0146378},{91.628,-0.0155668},{91.794,-0.0163348},{91.961,-0.0169818},{92.128,-0.0169748},{92.294,-0.0172568},{92.461,-0.0175498},{92.628,-0.0179148},{92.794,-0.0181788},{92.961,-0.0185558},{93.127,-0.0190238},{93.294,-0.0195868},{93.461,-0.0203297},{93.627,-0.0209477},{93.794,-0.0215587},{93.961,-0.0222417},{94.127,-0.0228417},{94.294,-0.0235187},{94.461,-0.0242437},{94.627,-0.0249517},{94.794,-0.0259347},{94.96,-0.0270387}}


Which plotted using ListPlot[data, PlotRange -> All] gives:

Questions:

1. Is there any way to get the discrete data points that you see for instance when you plot this data using ListLinePlot (example:ListLinePlot[data, PlotRange -> All]) which joins the data points?. In other words, besides the provided data to also obtain discrete data points that join all the data (this is more visible for the last peak)

2. Another way to ask this is if there is a way to get all the discrete data points that you get when you interpolate the data such as f = Interpolation[data] as to obtain more "complete" connected data?

Thank you

When you call on ListLinePlot, it interpolates the data in the background. It then samples from that interpolation function. We don't know exactly what the sampling algorithm looks like, but one such algorithm used by Mathematica in some contexts is described in the question How to implement the sample-point process like the built-ins of Mathematica?.

However, what we do know is which points it sampled:

samplePts = Cases[ListLinePlot[
data,
InterpolationOrder -> 2,
PlotRange -> Full
], Line[pts_] :> pts, Infinity];
samplePts // Shallow


{{{<<2>>}, {<<2>>}, {<<2>>}, {<<2>>}, {<<2>>}, {<<2>>}, {<<2>>}, \ {<<2>>}, {<<2>>}, {<<2>>}, <<2047>>}}

We cannot extract the same points from an InterpolationFunction as ListLinePlot does since we do not know what algorithm is uses to select them, but we can obtain similar results using an algorithm like the ones in the Q&A that I mentioned.

• C.E thank you very much for your answer!. samplePts is very close to what I was looking for! thanks !! – John Jul 10 '20 at 16:29