【发布时间】:2021-08-15 12:56:57
【问题描述】:
我有一个数据框:
surfacex surfacey surfacez
0 -0.50 0.00 0.00
1 -0.48 -0.14 0.00
2 -0.48 -0.12 -0.06
3 -0.48 -0.12 0.06
4 -0.48 -0.10 -0.08
... ... ... ...
3897 0.48 0.10 0.08
3898 0.48 0.12 -0.06
3899 0.48 0.12 0.06
3900 0.48 0.14 0.00
3901 0.50 0.00 0.00
每行代表一个 3D 点。我想绘制一个限定这些点的表面。在这种情况下,这些点都位于球体的表面上,因此我想绘制一个球面。目前这是我正在尝试的:
import numpy as np
import plotly.graph_objects as go
X=df['surfacex'].values
Y=df['surfacey'].values
Z=df['surfacez'].values
trace= go.Surface(x=np.reshape(X,(1951,2)),y=np.reshape(Y,(1951,2)),z=np.reshape(Z,(1951,2)))
#I am reshaping as online tells me it needs to be a 2D array, and my df is of length 3902
fig2=go.Figure(data=[trace])
fig2.show()
但是,结果图如下所示:
这显然不是我想要的。我想要的是类似于:
我怎样才能达到想要的情节? Matplotlib 或 plotly 解决方案都可以
谢谢
【问题讨论】:
标签: python matplotlib plot