本文整理汇总了Python中plotly.tools.FigureFactory._trisurf方法的典型用法代码示例。如果您正苦于以下问题:Python FigureFactory._trisurf方法的具体用法?Python FigureFactory._trisurf怎么用?Python FigureFactory._trisurf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类plotly.tools.FigureFactory
的用法示例。
在下文中一共展示了FigureFactory._trisurf方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: add_surface
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import _trisurf [as 别名]
def add_surface(self, xyz, triangles, lighting=None, **kwargs):
"""Add a surface model to the plotly figure.
xyz : array, shape (n_vertices, 3)
An xyz array defining the position of each vertex in 3-D
triangles : array, shape (n_triangles, 3)
An ijk array defining triangles for the mesh. Each row
indexes 3 rows of in xyz, which together make a triangle.
lighting : None | dict
A dictionary specifying lighting parameters in plotly
"""
if lighting is None:
lighting = dict(ambient=.4, specular=1)
self.xyz = xyz
self.x = xyz.T[0]
self.y = xyz.T[1]
self.z = xyz.T[2]
self.triangles = triangles
self.xrange = np.array([xyz.min(0)[0], xyz.max(0)[0]])
self.yrange = np.array([xyz.min(0)[1], xyz.max(0)[1]])
self.zrange = np.array([xyz.min(0)[2], xyz.max(0)[2]])
colors = self.cmap(np.repeat(.5, len(triangles)))
colors = array_to_plotly(colors)
self.surfacedata = ff._trisurf(
x=self.x, y=self.y, z=self.z, simplices=self.triangles,
color_func=colors, **kwargs)
self.surfacedata[0]['lighting'] = lighting
self.facecolors = self.surfacedata[0]['facecolor'].copy()
self.tri_centroids = xyz[triangles].mean(1)
self.layout['scene'].update(dict(xaxis=dict(range=self.xrange),
yaxis=dict(range=self.yrange),
zaxis=dict(range=self.zrange)))
示例2: init_graph
# 需要导入模块: from plotly.tools import FigureFactory [as 别名]
# 或者: from plotly.tools.FigureFactory import _trisurf [as 别名]
def init_graph(self, plot_args, plot_kwargs):
if hasattr(FF, '_trisurf'):
trisurf = FF._trisurf(*plot_args[:-1], **plot_kwargs)
else:
trisurf = trisurface(*plot_args, **plot_kwargs)
return trisurf[0]