2
$\begingroup$

I used the below simple data (including 10 x-y data) and function ListLinePlot to draw a figure.

Enter image description here

The figure is this:

Enter image description here

Now I want to export a data x-y coordinates list which includes 100 x-y data at the same x axis interval. Like {1.0,5},{1.1,y1},{1.2,y2},{1.3,y3}...{9.9,y99},{10,7}

How can I do it?

$\endgroup$
1
  • $\begingroup$ Duplicate of 81228? $\endgroup$
    – Syed
    Apr 15, 2023 at 13:24

2 Answers 2

4
$\begingroup$

With pic=ListLinePlot[...] (your plot) you get the points from

pts=Cases[pic, Line[p_] :> p, -1][[1]]

y=Interpolation[pts,InterpolationOrder->1]
xy=Map[{#,y[#]}&,Range[1,10,.1](* your gridpoints x *)] 
$\endgroup$
2
  • $\begingroup$ thanks, Neumann! Using your answer, I just get 10 x-y coordinates output. I want to get 100 x-y points coordinates. $\endgroup$
    – Mr.2023
    Apr 14, 2023 at 10:22
  • $\begingroup$ I don't know your ListLinePlot. Try xy=Map[{#,y[#]}&, Range[1,10,.1]] $\endgroup$ Apr 14, 2023 at 10:48
3
$\begingroup$

You must interpolate your data. This can be done with the function "Interpolate" I assume that you want points that lay on your plot, therefore I am using InterpolationOrder->1 to get the points "pts":

d = {{1, 5}, {2, 8}, {3.5, 4}, {4.2, 6.9}, {5, 7.3}, {6.6, 11.6}, {7, 
    0.2}, {8.5, 5.5}, {9.3, 8.3}, {10, 7}};
interpol = Interpolation[d, InterpolationOrder -> 1];
pts = {#, interpol[#]} & /@ Range[1, 10, 9/100];
ListLinePlot[d, Epilog -> Point[pts]];

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.