Intuitive interpolation between unevenly spaced points

I have the following graph that I want to digitize for high quality publishing using Python and Matplotlib:

enter image description here

I used a digitizer program to capture multiple samples from one of three data sets:

x_data = np.array([
1,
1.2371,
1.6809,
2.89151,
5.13304,
9.23238,
])

y_data = np.array([
0.0688824,
0.0490012,
0.0332843,
0.0235889,
0.0222304,
0.0245952,
])

I already tried 3 different curve fitting methods through these data points. The first way is to draw a spline through the points usingscipy.interpolate import spline

As a result (with actual data points plotted as blue markers):

enter image description here

This is clearly not good.

My second attempt was to draw a curve using a series of different order polynyms using scipy.optimize import curve_fit. Even before the fourth-order polynomial, the answer is useless (lower orders were even more useless):

enter image description here

, scipy.interpolate import interp1d, . , , , , - :

enter image description here

, rubish, :

enter image description here

, , interp1d .

-, ? , IPE - ?

!

+4
1

, . , Scipy . :

enter image description here

import numpy as np
from scipy.interpolate import spline, UnivariateSpline, Akima1DInterpolator, PchipInterpolator
import matplotlib.pyplot as plt

x_data = np.array([1, 1.2371, 1.6809, 2.89151, 5.13304, 9.23238])

y_data = np.array([0.0688824, 0.0490012, 0.0332843, 0.0235889, 0.0222304, 0.0245952])

x_data_smooth = np.linspace(min(x_data), max(x_data), 1000)
fig, ax = plt.subplots(1,1)

spl = UnivariateSpline(x_data, y_data, s=0, k=2)
y_data_smooth = spl(x_data_smooth)
ax.plot(x_data_smooth, y_data_smooth, 'b')

bi = Akima1DInterpolator(x_data, y_data)
y_data_smooth = bi(x_data_smooth)
ax.plot(x_data_smooth, y_data_smooth, 'g')

bi = PchipInterpolator(x_data, y_data)
y_data_smooth = bi(x_data_smooth)
ax.plot(x_data_smooth, y_data_smooth, 'k')

ax.plot(x_data_smooth, y_data_smooth)
ax.scatter(x_data, y_data)

plt.show()

, , , , . , . , , PCHIP , (, , , ).

+7

All Articles