[英]Interactive 3D plot with numpy array
I have been using plotly
for dataframe visualisation, but when the data type is array, what is the best way to create an interactive plot, apart from converting array into dataframe? I have been using
plotly
for dataframe visualisation, but when the data type is array, what is the best way to create an interactive plot, apart from converting array into dataframe?
Code I previously used for dataframe:我之前用于 dataframe 的代码:
import plotly.express as px
fig = px.scatter_3d(df, x='col1', y='col2', z='col3',)
fig.update_traces(marker=dict(size=2,
line=dict(width=0.01)
)
)
fig.update_layout(showlegend=True,
width=900,
height=900,
title = 'My Plot')
fig.show()
If you mean that you have a numpy array whose columns (or rows) give the coordinates of points you want to plot, then you can assign these columns to the x
, y
and z
arguments:如果您的意思是您有一个 numpy 数组,其列(或行)给出了您想要 plot 的点的坐标,那么您可以将这些列分配给
x
、 y
和z
ZDBC11CAA5BDA99F77E6FB4DABD882E
import plotly.express as px
import numpy as np
X = np.random.randint(0, 10, (10, 3))
fig = px.scatter_3d(x=X[:,0], y=X[:, 1], z=X[:, 2])
fig.show()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.