Plotly.py: Hover over filled area: incorrect text

Created on 21 Apr 2020  路  4Comments  路  Source: plotly/plotly.py

I'm trying to build a stacked area chart, starting from the example provided here.

However, the hover text does not always match the hovered area. In the following screen shot, I'm actually over the blue area, close to y = 0.
image

I'm using the following code to plot online (the aim is to use this in a Dash application).

import plotly.graph_objects as go

fig = go.Figure()
for i, y in enumerate([0, 1]):
    values=[i, 1 + i, 2 + i, 1 + i, i]
    fig.add_trace(go.Scatter(x=[0, 1, 2, 3, 4], y=values,
                             stackgroup="one",
                             hoveron = 'points+fills', # select where hover is active
                             name=f"Trace {y}",
                             text=[f"<span>Value: {v}</span>" for v in values],
                             hoverinfo = 'text+x'))
fig.update_layout(
    title = "hover on <i>points</i> or <i>fill</i>",
)

Also, with the same setting, the label is wrong : withhoverinfo='text+x', the text in the hover is the name of the trace. Note that the hovers on the markers are correct.

Most helpful comment

Ah, I see. I was referring to the contents of the hover-label, and confirming that indeed when hovering on fills, you only get to see the trace name and this is by design today.

If you're seeing issues where the wrong hover-label is showing up, this is probably something that we need to bring up in the Plotly.js repo. I'll try to pull together a minimal JS-only CodePen.

All 4 comments

I second to this. Hover markers simply do not show the correct label, especially when there are many stacked zero areas on top of each other.

Today, hovering on areas gives very limited information: just the trace name. This isn't a bug so much as an incompletely-implemented feature :)

Sample-72-Subtype-3-Jupyter-Note

@nicolaskruchten if this behavior is not a bug, I do not know what is. The hover info is far from stable, and it usually misses the line or area that I want. First I thought it was related to plotly/plotly.js#2165, but the error persists even without fills parameter.

P.S. here's the code snippet. I know that some variables are missing (I can't provide the whole code), but the idea should be there.

fig_ud = go.Figure()
fill = 'tozeroy'
for key, group in melted_df.groupby('Delay type'):
    fig_ud.add_trace(
        go.Scatter(x = group['timestamp'], y = group['Sample count'],
                         fill=fill, name = key, stackgroup = 'x',
                         mode='none')
    )
    fill = 'tonexty'

Ah, I see. I was referring to the contents of the hover-label, and confirming that indeed when hovering on fills, you only get to see the trace name and this is by design today.

If you're seeing issues where the wrong hover-label is showing up, this is probably something that we need to bring up in the Plotly.js repo. I'll try to pull together a minimal JS-only CodePen.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hiramf picture hiramf  路  5Comments

vlizanae picture vlizanae  路  4Comments

jonmmease picture jonmmease  路  3Comments

jisaacso picture jisaacso  路  4Comments

aplowman picture aplowman  路  3Comments