好吧,比我想象的要容易。有一个alphahull选项,它要求自动计算相应的三角剖分。在from plotly.offline import iplot, init_notebook_mode
from plotly.graph_objs import Mesh3d
from numpy import sin, cos, pi
# some math: generate points on the surface of ellipsoid
phi = np.linspace(0, 2*pi)
theta = np.linspace(-pi/2, pi/2)
phi, theta=np.meshgrid(phi, theta)
x = cos(theta) * sin(phi) * 3
y = cos(theta) * cos(phi) * 2
z = sin(theta)
# to use with Jupyter notebook
init_notebook_mode()
iplot([Mesh3d({
'x': x.flatten(),
'y': y.flatten(),
'z': z.flatten(),
'alphahull': 0
})])
这是R版:
^{pr2}$
编辑:也可以使用type='surface'生成参数图:在这种情况下,必须提供二维x和{}。在library(plotly)
library(pracma)
mgrd
U
V
frame
plot_ly(frame, type='surface', x=x, y=y, z=z, showlegend=F, showscale=F,
colorscale=list(list(0, 'blue'), list(1, 'blue')))