Thursday, February 24, 2022

Python Interpolation of smooth curve

 Code sample

(.env) [boris@fedora34server NUMPY]$ cat interpolation.py

import numpy as np

import numpy as np

from scipy.interpolate import make_interp_spline

import matplotlib.pyplot as plt

# Dataset

x = np.array([1, 2, 3, 4, 5, 6, 7, 8])

y = np.array([20, 30, 5, 12, 39, 48, 50, 3])

X_Y_Spline = make_interp_spline(x, y)

# Returns evenly spaced numbers

# over a specified interval.

X_ = np.linspace(x.min(), x.max(), 500)

Y_ = X_Y_Spline(X_)

# Plotting the Graph

plt.plot(X_, Y_)

plt.title("Plot Smooth Curve Using the scipy.interpolate.make_interp_spline() Class")

plt.xlabel("X")

plt.ylabel("Y")

plt.show()































1 comment:

  1. Borgata Hotel Casino & Spa Launches First Ever Atlantic City
    The Borgata 세종특별자치 출장마사지 Hotel Casino & 양산 출장샵 Spa in 대전광역 출장마사지 Atlantic 여수 출장마사지 City, New Jersey, USA officially launched 충청남도 출장안마 a new $300 million Atlantic City resort and

    ReplyDelete