File indexing completed on 2026-04-09 07:48:50
0001
0002 """
0003
0004
0005
0006
0007 """
0008 import matplotlib.pyplot as plt
0009 import numpy as np
0010 import scipy as sp
0011
0012
0013 xd = np.array([0., 1., 1., 2.])
0014 yd = np.array([1., 2., 0., 1.])
0015
0016 inp = {}
0017
0018 kinds = "linear nearest previous next".split()
0019 kinds += "zero slinear".split()
0020
0021
0022
0023 for kind in kinds:
0024 inp[kind] = sp.interpolate.interp1d(xd, yd, kind=kind )
0025 pass
0026
0027 fig, axs = plt.subplots(1)
0028 ax = axs
0029
0030 x = np.linspace(0, 2, 500)
0031 for kind in kinds:
0032 ax.plot(x, inp[kind](x), label=kind )
0033 pass
0034
0035 plt.legend()
0036 fig.show()
0037
0038