如何在Python中基于散点图颜色制作轮廓图?

时间:2019-12-15 13:26:56

标签: python plot plotly scatter

我有一些传感器数据,例如https://raw.githubusercontent.com/iulianastroia/csv_data/master/final_dataframe.csv。我已经使用隔离林算法计算了ch2o列的异常点。我已经根据是否存在异常在散点图中显示了数据(异常颜色代码为红色,正常数据为蓝色)。 我已经像这样使用Plotly制作了散点图:

    fig_outliers = go.Figure(
        data=go.Scatter(x=dates, y=df['ch2o'], mode='markers',
                        marker=dict(color=np.where(df['anomaly'] == 1, 'red', 'blue'))))

enter image description here  现在,我要绘制蓝色散点的轮廓,以将其与红色散点分开。如何在Python中实现?像这样的东西:enter image description here

1 个答案:

答案 0 :(得分:0)

签出matplotlib.pyplot.contour

我想这就是你想要的

相关问题