# Linear interpolation from scipy.interpolate import interp1d import matplotlib.pyplot as plt plt.style.use("seaborn-poster") x = [0, 1, 2] y = [1, 3, 2] f = interp1d(x, y) y_hat = f(1.5) print(y_hat) my_dpi=100 plt.figure(figsize = (795/my_dpi,447/my_dpi),dpi=my_dpi) plt.plot(x, y, "-ob") plt.plot(1.5, y_hat, "ro") plt.title("Linear Interpolation at x = 1.5") plt.xlabel("x") plt.ylabel("y") plt.savefig('ex198.png', dpi=my_dpi) plt.show()
Recent Comments