Skip to content

howto: colorbar in FigureFactory.create_trisurf() #517

Closed
@ntfrgl

Description

@ntfrgl

For many applications, a colour bar is essential for visual interpretation, but I couldn't find a parameter or example in the documentation indicating how to add one to a trisurf rendering. Based on the documentation on trisurf, surface coloring and meshes, I guessed that adding a colour bar dict into the Mesh3d data could do the job, but this was ineffectual. What would be the right way?

Below is an example for ipython notebook using a mesh from the FAUST dataset, the trimesh library and the default trisurf colouring (z-value). The line before the last is my failed attempt.

import trimesh
mesh = trimesh.load_mesh('tr_reg_003.ply')
x, y, z = mesh.vertices.T
size = (mesh.vertices.max(axis=0) - mesh.vertices.min(axis=0)).T

import plotly.offline as py
import plotly.graph_objs as go
from plotly.tools import FigureFactory as ff
py.init_notebook_mode()
fig = ff.create_trisurf(
    x=x, y=y, z=z, simplices=mesh.faces, colormap='Viridis',
    aspectratio={'x': size[0], 'y': size[1], 'z': size[2]})
fig.data[0].update(colorbar=go.ColorBar(title='z'))
py.iplot(fig)

Also, an option for create_trisurf() setting the aspect ratio based on the mesh extent (as done above manually) would be useful.
no_colorbar

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions