KDE 图的 Seaborn 加权平均线

Seaborn weighted average line for KDE plot

有谁知道如何将参考线图添加到代表每个 x 值的中位数的 kdeplot 中。

我试图通过汉明滤波器应用卷积来平滑它,但它看起来不太好。

最后通过绘图解决了

# create an aggregation ef
ef = df[['Temp','Power]].groupby('Temp').median().reset_index()

# smooth the aggregation with mean() - shift(- half window) is needed for alignment
ef['roll_med_power'] = ef['Power'].rolling(5).mean().shift(-2)

# finally close the gaps at beginning and end with unsmoothed data
ef['roll_med'][:2] = ef['Power'][:2]
ef['roll_med'][-2:] = ef['Power'][-2:]