1

I have a numpy array coordinates which contains certain number of x-y coordinates. The elements of the array are:

coordinates = [[101 161]
 [104 187]
 [109 212]
 [117 237]
 [130 260]
 [147 282]
 [166 301]
 [189 317]
 [215 319]
 [240 309]
 [261 290]
 [280 266]
 [293 239]
 [299 211]
 [299 181]
 [297 153]
 [294 124]
 [107 149]
 [113 133]
 [129 125]
 [147 124]
 [163 129]
 [195 124]
 [212 113]
 [231 108]
 [251 108]
 [267 119]]

The corresponding scatter plot of the above points is shown below:

enter image description here

Now, I want to connect all the points and generate a smooth curve(as smooth as possible). How can I do that using numpy/scipy?

P.S: I have looked at the documentation of scipy's various interpolation method but I don't know which one will be better for my case and why?

enterML
  • 2,110
  • 4
  • 26
  • 38
  • Can you post your code? https://stackoverflow.com/help/mcve – Isma Sep 12 '17 at 08:26
  • Test the various interpolation methods and judge yourself. – Ignacio Vergara Kausel Sep 12 '17 at 08:29
  • The curve that your coordinates represent is not a single-valued function of x, "y = f(x)". Solutions: 1. consider two functions "x(s)" and "y(s)" representing your curve (see Wikipedia's [Parametric equation](https://en.wikipedia.org/wiki/Parametric_equation) page) and use twice the 1D method. 2. Cut your coordinates in the "lower curve" and the "upper curve" and use twice the 1D method for "y(x)". – Pierre de Buyl Sep 12 '17 at 08:42
  • @PierredeBuyl What about spline? – enterML Sep 12 '17 at 08:50

0 Answers0