1from scipy.interpolate import make_interp_spline, BSpline
2
3#create data
4x = np.array([1, 2, 3, 4, 5, 6, 7, 8])
5y = np.array([4, 9, 12, 30, 45, 88, 140, 230])
6
7#define x as 200 equally spaced values between the min and max of original x
8xnew = np.linspace(x.min(), x.max(), 200)
9
10#define spline
11spl = make_interp_spline(x, y, k=3)
12y_smooth = spl(xnew)
13
14#create smooth line chart
15plt.plot(xnew, y_smooth)
16plt.show()
17