1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| import numpy as np import plotly as py import plotly.graph_objs as go
x1, y1, z1 = np.random.multivariate_normal(np.array([0,0,0]), np.eye(3), 200).transpose() trace1 = go.Scatter3d( x=x1, y=y1, z=z1, mode='markers', marker=dict( color='rgb(217, 217, 217)', size=12, symbol='circle', opacity=0.8 ) )
x2, y2, z2 = np.random.multivariate_normal(np.array([0,0,0]), np.eye(3), 200).transpose() trace2 = go.Scatter3d( x=x2, y=y2, z=z2, mode='markers', marker=dict( color='rgb(127, 127, 127)', size=12, symbol='circle', opacity=0.8 ) )
data = [trace1, trace2]
layout = go.Layout( title='三维散点', autosize=True, margin=dict( l=65, r=50, b=65, t=90 ) )
fig = go.Figure(data=data, layout=layout)
py.offline.plot(fig, filename='test.html', auto_open=True)
|