diff options
Diffstat (limited to 'numpy/lib/function_base.py')
-rw-r--r-- | numpy/lib/function_base.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 5ca797864..19037d975 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1128,6 +1128,17 @@ def interp(x, xp, fp, left=None, right=None): >>> np.interp(3.14, xp, fp, right=UNDEF) -99.0 + Plot an interpolant to the sine function: + + >>> x = np.linspace(0, 2*np.pi, 10) + >>> y = np.sin(x) + >>> xvals = np.linspace(0, 2*np.pi, 50) + >>> yinterp = np.interp(xvals, x, y) + >>> import matplotlib.pyplot as plt + >>> plt.plot(x, y, 'o') + >>> plt.plot(xvals, yinterp, '-x') + >>> plt.show() + """ if isinstance(x, (float, int, number)): return compiled_interp([x], xp, fp, left, right).item() |