2

I'm new to plotly for python, and ran into a problem today: when I do scatter plots, hover display only works if the points have different x values. Please see the attached example.

I've tried formatting hoverinfo as "x+y", but it didn't make a difference. Is there a workaround for this, so I can display entries with different y values but same x value? Many thanks in advance for the help!

x=np.zeros(10)
y=np.arange(0,10,1)
trace1=go.Scatter(x=x, y=y)
data1=[trace1]
`enter code here`plotly.offline.iplot(data1)

only one hover label shows up: only one hover label shows up

1

1 Answer 1

3

Try setting hovermode to closest in layout.

import plotly
plotly.offline.init_notebook_mode()

x = [0] * 10
y = [y for y in range(0, 10)]
data = [plotly.graph_objs.Scatter(x=x, y=y)]
layout = plotly.graph_objs.Layout(hovermode='closest')
figure = plotly.graph_objs.Figure(data=data, layout=layout)
plotly.offline.iplot(figure)

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.