[英]How to make a contour plot based on scatter plot colors in Python?
I have some sensor data like this one https://raw.githubusercontent.com/iulianastroia/csv_data/master/final_dataframe.csv .我有一些像这样的传感器数据https://raw.githubusercontent.com/iulianastroia/csv_data/master/final_dataframe.csv 。 I have calculated the anomaly points of ch2o column using the isolation forest algorithm.我已经使用隔离森林算法计算了 ch2o 列的异常点。 I have displayed the data in a scatter plot based on anomaly or not(anomaly color code is red and normal data is blue).我已经在基于异常与否的散点图中显示了数据(异常颜色代码为红色,正常数据为蓝色)。 I have made a Scatter plot using Plotly like this:我使用 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'))))
Now I want to contour the blue scatter points, to separate them from the red ones.现在我想绘制蓝色散点的轮廓,将它们与红色散点分开。 How can I achieve this in Python?我怎样才能在 Python 中实现这一点? Something like this:像这样的东西:
Check out matplotlib.pyplot.contour查看matplotlib.pyplot.contour
I guess this is what you want我想这就是你想要的
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.