参考资料:https://www.freesion.com/article/4083301505/

    1. # 2-D数据平滑
    2. import numpy as np
    3. from matplotlib import pyplot as plt
    4. from scipy.interpolate import make_interp_spline
    5. x = np.array([6, 7, 8, 9, 10, 11, 12])
    6. y = np.array([1.53E+03, 5.92E+02, 2.04E+02, 7.24E+01, 2.72E+01, 1.10E+01, 4.70E+00])
    7. x_smooth = np.linspace(x.min(), x.max(), 300)
    8. y_smooth = make_interp_spline(x, y)(x_smooth)
    9. plt.plot(x, y)
    10. plt.show()
    11. plt.plot(x_smooth, y_smooth)
    12. plt.show()

    image.png
    image.png