Black Lives Matter. Please consider donating to Black Girls Code today.

Setting up hoverinfo property to display 'intensity' values in Mesh3d in Python

This seems like it might be a relatively easy thing to do, but I’m too inexperienced in coding to figure it out. I would like to setup the ‘hoverinfo’ method of the Mesh3d class to accept ‘intensity’ as a valid string, and thus display the intensity values on mouse hover. It is currently setup to accept ‘x’, ‘y’, ‘z’, ‘text’, or ‘name’. My current workaround is to create a separate list that contains strings of the intensity values, assign that as the “text” option in Mesh3d, and use ‘text’ in the hoverinfo property. Using a similar example as shown on the Plotly website for a tetrahedron, my workaround looks like:

import plotly.graph_objs as go
import numpy as np
import plotly
intensity=[0, 0.33, 0.66, 1]
intensityString=['0','0.33','0.66','1']
data = [
    go.Mesh3d(
        x = [0, 1, 2, 0],
        y = [0, 0, 1, 2],
        z = [0, 2, 0, 1],
        intensity = intensity,
        i = [0, 0, 0, 1],
        j = [1, 2, 3, 2],
        k = [2, 3, 1, 3],
        name = 'y',
        showscale = True,
        text=intensityString,
        hoverinfo='text'
    )
]
fig = go.Figure(data=data)
plotly.offline.plot(fig)

It seems like it should be relatively easy to set things up so that there is no need to create that extra list called intensityString…especially since hoverinfo can already take and display the x y and/or z-cords, but I get lost in where I might be able to do that in the source code. What I have works just fine, but, for a mesh with a lot of data, it will slow things down considerably.