0
votes

Using Jupyter Notebooks, I made a Scatterpolar plot with two traces on it using the following code:

import numpy as np
import plotly.graph_objs as go

th = np.arange(0, 361, 1)
r1 = np.random.randn(360)
r2 = np.random.randn(360)

fig = go.Figure()
fig.add_trace(go.Scatterpolar(r=r1, theta=th, mode='lines'))
fig.add_trace(go.Scatterpolar(r=r2, theta=th, mode='lines'))
fig.update_layout(hovermode='x')

It results in this figure, which does not show both data points when I hover over the plot. I'd like it to show both data points.

enter image description here

For example, when you have a line plot, it's easy to do. You just change hovermode = 'x' and you get this as shown in the hovermode text and formatting documentation.

enter image description here

How can I make my Scatterpolar plot show both data points when I hover over the plot? Any help would be greatly appreciated.

1

1 Answers

0
votes

I don't know if I fully comprehended your final objective, but the first thing you can do to make the scatter plots less messy, is to make the change mode='markers'. By default, a single hover label will appear for the point underneath the cursor, so if you hover over a point with (r1, th) coordinates these will show in the label, with the same happening for points with (r2, th). Now for the case you presented, the line fig.update_layout(hovermode='x unified') doesn't make any difference to the result.