python笔记之matplotlib.pyplot曲线平滑自定义函数:smooth

python笔记之matplotlib.pyplot曲线平滑自定义函数:smooth,第1张

python笔记之matplotlib.pyplot曲线平滑自定义函数:smooth

做个笔记

代码

import matplotlib.pyplot as plt
import numpy as np
from scipy.interpolate import make_interp_spline

def smooth_curv(label_str,y):
    x_array=np.arange(1,len(y)+1)
    y_array=np.array(y)
    x_smooth = np.linspace(x_array.min(), x_array.max(), 100)
    y_smooth = make_interp_spline(x_array,y_array)(x_smooth)
    plt.plot(x_smooth, y_smooth,label=label_str)

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/4682674.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-07
下一篇2022-11-07

发表评论

登录后才能评论

评论列表(0条)

    保存