Matplotlib KDE图的Seaborn加权平均线

Matplotlib KDE图的Seaborn加权平均线,matplotlib,seaborn,line-plot,Matplotlib,Seaborn,Line 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 alignme

有人知道如何将参考线图添加到表示每个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:]

我认为这个问题不是特别清楚。numpy数组的中值可以通过
np.median()
获得。问题是在
x=np.中线(数据)
处绘制垂直线吗?谢谢您的帮助。我有一个KDEplot(显示一些密度云),现在我想要一条曲线,表示每个x坐标的中值(基本上是沿着最密集的区域分割一个云)哦,那就是一个2D KDEplot?我建议你用更多的话来解释问题和期望的结果。另外,如果您提供一些代码示例,人们可能更倾向于使用它并提供答案。