Here is another option if you want to use another spline function:
from matplotlib import pyplot import numpy from scipy import interpolate widths = numpy.array([0, 30, 60, 90, 120, 150, 180]) heights = numpy.array([26, 38.5, 59.5, 82.5, 120.5, 182.5, 319.5]) xnew = numpy.linspace(widths.min(),widths.max(),300) heights_smooth = interpolate.splrep(widths,heights)
Then
In[]: heights Out[]: array([ 26. , 74.1721985 , 44.47929453])
Or evaluate at:
w = 167.2 heights = interpolate.splev(w, heights_smooth) height = heights.item() In[]: height Out[]: 247.8396196684303
The .item()
function is necessary because splev
returns array()
source share