import numpy as np from scipy.interpolate import CubicSpline # Step 1: Data points y_values = [your_series_of_numbers] # Replace with your data x_values = np.arange(len(y_values)) # Generate x-values # Step 2: Create cubic spline cs = CubicSpline(x_values, y_values) # Step 3: Evaluate spline at finer points x_fine = np.linspace(x_values[0], x_values[-1], num=100) y_fine = cs(x_fine) # Now you can plot x_fine vs. y_fine to visualize the spline
import matplotlib.pyplot as plt plt.plot(x_values, y_values, 'o', label='Data Points') plt.plot(x_fine, y_fine, label='Cubic Spline') plt.legend() plt.show()