Skip to content
Advertisement

Plotly – how to display y values when hovering on two subplots sharing x-axis

I have two subplots sharing x-axis, but it only shows the y-value of one subplot not both. I want the hover-display to show y values from both subplots.

Here is what is showing right now: image1

But I want it to show y values from the bottom chart as well even if I am hovering my mouse on the top chart and vice versa.

Here’s my code:

JavaScript

Advertisement

Answer

Edit: At this time, I don’t think a Unified hovermode across the subplots will be provided. I got the rationale for this from here. It does affect some features, but this can be applied to work around it. In your example, the horizontal line does not appear on both graphs. So, I have added two horizontal lines in line mode for scatter plots to accommodate this. With the two stock prices, you have set a threshold value for each. Your objective is the same threshold value, so please modify that.

JavaScript

enter image description here

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement