python 函数插值总结

数据插值方式总结

Scipy 一维数据插值

曲线最好能有函数关系

详见:

https://docs.scipy.org/doc/scipy/reference/generated/scipy.interpolate.interp1d.html
‘’’
class scipy.interpolate.interp1d(x, y, kind=‘linear’, axis=-1, copy=True, bounds_error=None, fill_value=nan, assume_sorted=False)[source]
Interpolate a 1-D function.

x and y are arrays of values used to approximate some function f: y = f(x). This class returns a function whose call method uses interpolation to find the value of new points.
‘’’

import numpy as np
from scipy import interpolate  # 插值 Class
import pylab as pl
import matplotlib.pyplot as plt
import pandas as pd
from pandas import  DataFrame

带有 显示函数关系的插值

plt.figure(1, figsize=(40, 20))
x=np.linspace(0,10,11)
#x=[  0.   1.   2.   3.   4.   5.   6.   7.   8.   9.  10.]
y=np.sin(x)
xnew=np.linspace(0,10,101)
plt.plot(x,y,"ro")

for kind in ["nearest

你可能感兴趣的:(python)