有人知道如何将参考线图添加到表示每个x值中位数的kdeplot中。
我尝试通过使用汉明滤镜进行卷积来使其平滑,但效果并不理想。
答案 0 :(得分:0)
最后,我通过绘图解决了
# 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:]