Scatter hovertext not working for points that share y value


#1

I am trying to get unique hovertext to show up upon hovering over each point, but this is not working for points that share a y value.

When I try to hover over any of these points, only the hovertext “test 4” shows up. Any ideas for how I can get hoverinfo to appear when hovering over each individual point?

Code:

tr = go.Scatter(
    x = [1,1,1,1,1],
    y = [0,1,2,3,4],
    text = ["test " + str(i) for i in range(10)],
    mode = 'markers+text',
    name = 'markers',
    hoverinfo='text',
    hovertext = ["test " + str(i) for i in range(10)],
    textposition = 'bottom',
    hoveron = 'points'
)

layout = go.Layout(
    xaxis = dict(
        ticks='',
        zeroline=False,
        showticklabels=False
    ),
    yaxis = dict(
        zeroline=False,
        showline=False,
        ticks='',
        showticklabels=False
    ),
    showlegend=False,
)

fig = go.Figure(data=[tr], layout=layout)
iplot(fig)

#2

Just solved this problem - had to add hovermode=‘closest’ in the layout.


#3

For reference, https://plot.ly/python/reference/#layout-hovermode