✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Completely excluding a trace from hover info/snapping

Hi,

I have a scenario where my figure contains a mesh3d with scatter3d on top of it. Problem is that I only need howverinfo from scatter3d. The intention is to have mesh3d just as a background, data coming from scatter3d

I have set hovermode for mesh3d to “none” (tried “skip” too), but there are two issues with that.

  • mouse cursor still snaps to mesh vertices
  • since it’s 3d, some points of scatter3d are “inside” or obscured by mesh3d (I’ve made it almost transparent.). When hovering over obscured scatter3d points, cursor doesn’t snap to them, it snaps to mesh3d instead and no hover data is displayed, since mesh3d takes over.

re-ordering traces doesn’t help.

Any ideas would be greatly appreciated.

Hi @asm_34

Set hoverinfo='skip' in your Meshd trace definition. Depending on what surface is represented by Mesh3d, you can perform a trick, as I did for the sphere and 3d points in this image:

I increased with 0.05 the radius of the sphere on which the 3d points are plotted, to avoid getting obscured points.

1 Like

Thanks for your reply. Unfortunately hoverinfo=‘skip’ doesn’t solve the issue, as mouse cursor still snaps to mesh vertices, it only stops displaying hoverinfo.
Shrinking the mesh is not an option in my case due to mesh complexity.

Can’t really show the traces, but maybe that will give you a bit of idea what I am dealing with.

Annotation 2020-03-05 141432

@asm_34

I don’t understand what are you meaning by ...mouse cursor snaps to mesh I cannot catch the sense of the verb to snap, used in this context.

Mouse cursor snaps to vertices of the mesh3d (at least seems like it) when moved - similar to how it snaps to points in a scatter graph for example.

In my case it makes selecting scatter3d points difficult.

Thanks for your help so far - I’ll try to get an example together in next couple of days.

I have the exact same use case and accompanying issue. I am trying to use the mesh as an overlay, however neither of the ‘skip’ or ‘none’ settings appear to disable the hover behavior. Only the data points that form the vertices of the mesh trace are hover-able. The underlying scatter3d trace appears to not respond to hover events. I’ve attached a screenshot to help visualize the problem.

Hi @Afroz,
Could you, please, paste here your definition of Mesh3d and Scatter3d trace? Also be more precise and tell what do you intend to be displayed on hover and what not.

I am hoping to use the mesh purely as an overlay with no hover events. The goal is to be able to hover only on the scatter trace markers. Currently, the mesh trace appears to be preventing any hover events on the scatter trace. My config is as basic as it gets:

[{
    alphahull: 7,
    opacity: 0.05,
    type: 'mesh3d',
    x: x,
    y: y,
    z: z,
    hoverinfo: 'skip'
},
{
    type: "scatter3d",
    mode: "markers+lines",
    x: x,
    y: y,
    z: z,
    text: t,
    hoverinfo: 'text',
    marker: {
        size: s,
        symbol: o,
        sizeref: 0.5,
    },
    line: {
        dash: 'dot',
        width: 1
    },
    transforms: [{
                type: "groupby",
                groups: c
            }]

@Afroz

For me it works with Plotly 4.5.4. Are you running an old Plotly version?

I’m on the latest js version: 1.52.3

Just to be clear, I can hover on some markers - however, only the scatter markers that coincide with the mesh vertices/markers can be hovered. This is a small subset of all markers.

Apologies, I just realized I’m on the Plotly.py support forum…

Hi,

I tried a similar version of the code :

fig = go.Figure(data=[
    go.Mesh3d(
        x=[0, 0, 1, 1, 0, 0, 1, 1],
        y=[0, 1, 1, 0, 0, 1, 1, 0],
        z=[0, 0, 0, 0, 1, 1, 1, 1],
        color='gray',
        i=[7, 0, 0, 0, 4, 4, 6, 6, 4, 0, 3, 2],
        j=[3, 4, 1, 2, 5, 6, 5, 2, 0, 1, 6, 3],
        k=[0, 7, 2, 3, 6, 7, 1, 1, 5, 5, 7, 6],
        opacity=0.5,
        hoverinfo='skip'
    ),
    go.Scatter3d(
        x=[0.2, 0.3, 0.4],
        y=[0.2, 0.3, 0.4],
        z=[0.2, 0.3, 0.4],
        mode="markers",
        hoverinfo='text',
        text=['1', '2', '3'],
        marker=dict(size=5, symbol="circle",
                    )
    ),
])

Unfortunately I need to zoom in a lot to have the information on my scatter3d. I would like to access without needing to zoom and have hover information of my point like 3dmesh doesn’t exist at all. Is it possible ? I’m using plotly 4.7 and it seems not working.

I have the same problem. Feitan’s code is a great minimal example of exactly my issue.

1 Like