# Hover question. how to info in all trace、

**URL:** <https://community.plotly.com/t/hover-question-how-to-info-in-all-trace/84893>\
**Category:** 📊 Plotly Python\
**Tags:** question\
**Created:** [June 2, 2024, 9:23am UTC](https://community.plotly.com/t/hover-question-how-to-info-in-all-trace/84893 "2024-06-02T09:23:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigbai](https://avatars.discourse-cdn.com/v4/letter/b/3d9bf3/32.png) [@bigbai](https://community.plotly.com/u/bigbai)\
**Post date:** [June 2, 2024, 9:23am UTC](https://community.plotly.com/t/hover-question-how-to-info-in-all-trace/84893/1 "2024-06-02T09:23:32Z")

</div>

【中文】  
我希望 当hover在某一位置，所有子图对应的数值信息都显示出来，而不是只有当前的子图显示。

- 所有子图已经共享x轴
- 已经设置hovermode=‘x unified’,

【Question】  
I hope that when hovering over a specific position, all subplots display the corresponding value information, instead of only the current subplot.

- All subplots share the x-axis.
- hovermode=‘x unified’ is already set.

self.figer = make\_subplots(rows=nrows, cols=ncols, shared\_xaxes=True,specs=specs, vertical\_spacing=0.05 ) # 画布的figer  
self.figer.update\_layout(  
# xaxis\_rangeslider\_visible=True,  
hovermode=‘x unified’,  
spikedistance=-1  
)  
效果还是不行

 ![问题-信息显示](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/c/c/cc7583880042107362fec58e3fa65a250e670d82.jpeg)

---

<div class="post-metadata">

**Author:** ![empet](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@empet](https://community.plotly.com/u/empet)\
**Post date:** [June 3, 2024, 11:45am UTC](https://community.plotly.com/t/hover-question-how-to-info-in-all-trace/84893/2 "2024-06-03T11:45:42Z")

</div>

@bigbai The same issue has been reported here [https://community.plotly.com/t/hoversubplots-axis-not-working-with-make-subplots/84239/](https://community.plotly.com/t/hoversubplots-axis-not-working-with-make-subplots/84239/), BUT IT’S NOT A BUG!!!

The `hoversubplots` works only with subplots created via layout `grid`, and by specifying explicitly the xaxis to which the trace(s) in each subplot cell is/are referenced to.

Calling `help(go.Layout.hoversubplots)` we find out that  
`If hoversubplots="axis", the hover include all stacked subplots` **using the same axis** , `when `hovermode` is set to "x", *x unified*, "y" or *y unified*.`

No let us inspect xaxis name of each trace defined via`make_sublots` with `shared_xaxes=True` in the code by @adamschroeder, posted here [https://github.com/plotly/plotly.py/issues/4603](https://github.com/plotly/plotly.py/issues/4603):

```auto
import plotly.graph_objects as go
from plotly import data
from plotly.subplots import make_subplots

df = data.stocks()

fig = make_subplots(rows=3, cols=1, shared_xaxes=True, vertical_spacing=0.03)
layout = dict(
    hoversubplots="axis",
    title="Stock Price Changes",
    hovermode="x",
    grid=dict(rows=3, columns=1), #THIS LINE IS SUPERFLUOUS
)

fig.add_trace(go.Scatter(x=df["date"], y=df["AAPL"], name="Apple"), row=1, col=1)
fig.add_trace(go.Scatter(x=df["date"], y=df["GOOG"], name="Google"), row=2, col=1)
fig.add_trace(go.Scatter(x=df["date"], y=df["AMZN"], name="Amazon"), row=3, col=1)
fig.update_layout(layout)
fig.show()

```

```auto
print(fig.data[0].xaxis, fig.data[1].xaxis, fig.data[2].xaxis)

```

Surprise!!! The displayed axes are `x x2 x3`, and by help on `hoversubplots="axis"`  
we conclude that the condition (same xaxis name) ensuring simultaneous hover of the 3 subplots is not fulfilled.  
**REMEMBER that setting `shared_xaxes=True` does not assign the same name to `xaxis` in all subplots.**

Another drawback is that in the above code are used two methods to define subplots: 1) calling `make_subplots(rows=3, cols=1)`  
which creates an array of subplot indices, (row, col), indexed from 1, i.e [[1,1], [2,1], [3,1]];

```
2) setting `grid=dict(rows=3, columns=1)`, which creates an array with indices from 0: [[0,0], [1, 0], [2, 0]] (I'll give an example below to show that this is the indexing rule).

```

Setting `grid` in layout of a `fig=make_subplots()` has no effect (it is neglected by plotly.js). Commenting out the grid setting leads to the same result.

To understand how to define mixed subplots with grid, call:

```auto
help(go.layout.Grid)

```

Finally, an example of subplots consisting in 4 traces, two referenced to the same xaxis, in order to ensure that `hoversubplots="axis"` is active, and two traces referenced to non-cartesian axes (go.Pie, and go.Scatterternary). Notice the row and col starting from 0, not from 1 like in the case of `make_subplots()`.

```auto
import plotly.graph_objects as go
import pandas as pd
from plotly import data

df = data.stocks()

fig=go.Figure([
    go.Scatter(x=df["date"], y=df["AAPL"], xaxis="x", yaxis="y", name="Apple"),
    go.Scatter(x=df["date"], y=df["GOOG"], xaxis="x", yaxis="y2", name="Google"),
    go.Pie(labels= ["AAPL", "GOOG"], values= [5, 2], domain=dict(row= 0, column=1)),
    go.Scatterternary(a= [2, 1, 3], b= [1, 3, 2], c= [3, 2, 1], mode= "markers")
])
fig.update_layout(width=750, height=550,
                  showlegend=False,
    hoversubplots="axis",
    title="Stock Price Changes",
    hovermode="x", #or "x unified" without dashed line
    
    grid = dict(rows=2, columns=2, #the grid cells (row, col): [[(0,0), (0,1)], [(1,0), (1,1)]
                subplots=[["xy", ""], #this grid attribute gives info on the position of each trace
                          ["xy2", ""]],
                xgap=0.1, 
                ygap=0.2),
    ternary=dict(domain=dict(row=1, column=1),
                 aaxis_title_text="A",
                 baxis_title_text="B",
                 caxis_title_text="C"
                ))

```

 ![subplots-by-grid](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/b/0/b0c6e52210dce74694e58b735f000bc667ca0c36.png)

---

<div class="post-metadata">

**Author:** ![adamschroeder](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/adamschroeder/32/17280_2.png) [@adamschroeder](https://community.plotly.com/u/adamschroeder)\
**Post date:** [June 3, 2024, 2:47pm UTC](https://community.plotly.com/t/hover-question-how-to-info-in-all-trace/84893/3 "2024-06-03T14:47:50Z")

</div>

That clarifies things. Thanks for sharing, @empet

Mojtaba added this [axis hoversubplots issue](https://github.com/plotly/plotly.js/issues/7011).

---

<div class="post-metadata">

**Author:** ![commongrackle](https://avatars.discourse-cdn.com/v4/letter/c/c5a1d2/32.png) [@commongrackle](https://community.plotly.com/u/commongrackle)\
**Post date:** [February 18, 2025, 3:24am UTC](https://community.plotly.com/t/hover-question-how-to-info-in-all-trace/84893/4 "2025-02-18T03:24:42Z")

</div>

Hi @empet, is there any way have the combined hover feature from this thread at the same time as x-axis labels for all subplots from this thread - [Subplots with shared x-axes BUT show x-axis for each plot - 📊 Plotly Python - Plotly Community Forum](https://community.plotly.com/t/subplots-with-shared-x-axes-but-show-x-axis-for-each-plot/34800/2)?

Even when I set the tick labels for all x-axes to true `fig.update_layout(xaxis_showticklabels=True, xaxis2_showticklabels=True)`, I get this

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/7/e/7edb7e15c0528ffeaa8f974cb1d24aebbf015f35.png)
