Bootstrap

【收藏】如何优雅的在 Python matplotlib 中制作平滑线/趋势线

有时候需要在绘制曲线的时候,绘制一条趋势线,如下图,这种如何实现呢,请看下文。
在这里插入图片描述

数据如下

在这里插入图片描述

趋势计算代码

有两个输入
第一个输入是一个待平滑的数值数组,
第二个输入是权重,越大越平滑

# weight between 0 and 1, the larger the smoother
# scalars is the input list
def smooth(scalars, weight):  
    last = scalars[
;