Skip to content

Figure with multiple matching go.Scattergl traces have wrong hover order #4018

@lamhoangtung

Description

@lamhoangtung

Hi. I discover that figure with multiple matching go.Scattergl traces have wrong hover order. Consider this example:

import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(go.Scattergl(
    x=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], y=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    line_color='rgb(0,100,80)',
    name='Normal',
))

fig.add_trace(go.Scattergl(
    x=[5, 6], y=[5, 6],
    mode='markers',
    marker_color='rgb(255,0,0)',
    name='Abnormal',
))

fig.show()

I get this plot:
image
When I hover on the [5,5] points, the hover text should be in Red and say "Abnormal", but its not.

If I flip the trace order like this:

import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(go.Scattergl(
    x=[5, 6], y=[5, 6],
    mode='markers',
    marker_color='rgb(255,0,0)',
    name='Abnormal',
))

fig.add_trace(go.Scattergl(
    x=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], y=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    line_color='rgb(0,100,80)',
    name='Normal',
))

fig.show()

I get this plot:
image
Which have the correct hover text, but all the red markers are behind the green markers.

This does not happen for normal go.Scatter trace:

import plotly.graph_objects as go

fig = go.Figure()

fig.add_trace(go.Scatter(
    x=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], y=[1, 2, 3, 4, 5, 6, 7, 8, 9, 10],
    line_color='rgb(0,100,80)',
    name='Normal',
))

fig.add_trace(go.Scatter(
    x=[5, 6], y=[5, 6],
    mode='markers',
    marker_color='rgb(255,0,0)',
    name='Abnormal',
))

fig.show()

image

So clearly this is a bug. Can someone take a look and fix this ?

Thanks for checking by!

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