import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import CubicSpline
# Generate some sample data points
x = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
y = np.array([5, 6, 9, 8, 7, 4, 6, 7, 8, 5])
# Create a CubicSpline interpolation
cs = CubicSpline(x, y)
# Generate points for plotting the interpolated curve
x_interp = np.linspace(1, 10, 100)
y_interp = cs(x_interp)
# Plot original data points and interpolated curve
plt.figure(figsize=(8, 6))
plt.plot(x, y, 'o', label='Data Points')
plt.plot(x_interp, y_interp, label='Cubic Spline Interpolation')
plt.title('Cubic Spline Interpolation')
plt.xlabel('X')
plt.ylabel('Y')
plt.legend()
plt.grid(True)
plt.show()