三维数据可视化工具使用
import plotly.graph_objects as go
import numpy as np# 生成随机点
data = np.random.uniform(-3,3,(100000, 2))
Z = np.exp(-((data[:, 0] - 0)**2 / (2*1**2) + (data[:, 1] - 0)**2 / (2*1**2)))scatter1 = go.Scatter3d(x=data[:, 0], y=data[:, 1], z=Z, mode='markers', marker=dict(color='blue',size=1,opacity=0.8), name='data')
scatter2 = go.Scatter3d(x=[0], y=[0], z=[0], mode='markers', marker=dict(color='red',size=6,opacity=0.8), name='centroids')
fig = go.Figure(data=[scatter1, scatter2])fig.update_layout(width=1000,height=800,margin=dict(l=50, r=50, b=50, t=50)
)fig.update_layout(title='X-Y-Heading',scene=dict(xaxis_title='X',yaxis_title='Y',zaxis_title='Heading'),
)
# fig.write_html('path.html') # 以网页形式保存
fig.show()