When I attempt to create a shared hover spike across multiple subplots, I immediately lose the xticks on those subplots.
Is there any way I can fix this? I want to see the xtick labels on ALL of my subplots.
Reproducible Code:
from plotly.subplots import make_subplots
import plotly.graph_objects as go
fig = make_subplots(rows=3, cols=1,
shared_xaxes=True,
vertical_spacing=0.10)
fig.add_trace(go.Scatter(x=[0, 1, 2], y=[10, 11, 12]),
row=3, col=1)
fig.add_trace(go.Scatter(x=[2, 3, 4], y=[100, 110, 120]),
row=2, col=1)
fig.add_trace(go.Scatter(x=[3, 4, 5], y=[1000, 1100, 1200]),
row=1, col=1)
fig.update_layout(height=600, width=600,
title_text="Stacked Subplots with Shared X-Axes")
fig.update_layout(
xaxis_showticklabels=True,
xaxis2_showticklabels=True,
xaxis3_showticklabels=True,
)
# Uncomment these lines to draw the shared hover spike
# fig.update_traces(xaxis='x')
# fig.update_xaxes(spikemode='across+marker')
fig.show()
Before and After Chart
AIMPED
April 23, 2024, 9:18pm
2
HI @AlanPLOTLY welcome to the forums.
I actually think, that this is not possible, at least I did not find a way to do so. You can set where the ticks are shown by changing to fig.update_traces(xaxis='x'3)
however
Hi @AIMPED ,
The functionality is obviously there, are you sure there isnβt some flag I can set to βre-enableβ visibility on the hidden tick marks?
AIMPED
April 24, 2024, 4:47am
5
Hey @AlanPLOTLY .
No, Iβm not 100% sure .
To be sure Iβd have to dig deeper but I never have come across the flag you mention.
opened 02:34PM - 23 Jul 19 UTC
After upgrading to plotly 4.0.0, I can't see how to create a spike line across s⦠hared axes created with make_subplots.
Previously I was using code like this:
```python
from plotly.tools import make_subplots
from plotly.io import write_html
fig = make_subplots(rows=4, cols=1, shared_xaxes=True)
x_vals = list(range(10))
y_vals = [x**2 for x in x_vals]
fig.add_scatter(x=x_vals, y=y_vals, row=1, col=1)
fig.add_scatter(x=x_vals, y=y_vals, row=2, col=1)
fig.add_scatter(x=x_vals, y=y_vals, row=3, col=1)
fig.add_scatter(x=x_vals, y=y_vals, row=4, col=1)
fig.update_xaxes(spikemode='across+marker')
write_html(fig, 'out.html', auto_open=True)
```
The resulting figure showed spike lines across axes because only one x axis was created:
![image](https://user-images.githubusercontent.com/12515343/61720630-6ccb2480-ad67-11e9-8757-d4093d55d633.png)
But in 4.0, multiple x axes are created so the spike line no longer draws across all subplots:
![image](https://user-images.githubusercontent.com/12515343/61720563-4f965600-ad67-11e9-8709-c69a77d3daf1.png)
Is there any way around this? Thanks!