plotly / plotly/plotly.py

Can't draw spike line across subplots with make_subplots in 4.0.0

Open
#1,677 8 comments 5 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug P3
Dominant language
Python
Stars
18.8k
Forks
2.8k
Avg merge
16h 26m
Merged PRs (30d)
21

Description

After upgrading to plotly 4.0.0, I can't see how to create a spike line across shared axes created with make_subplots.

Previously I was using code like this:

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

But in 4.0, multiple x axes are created so the spike line no longer draws across all subplots:
image

Is there any way around this? Thanks!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided Python reproduction using make_subplots, shared_xaxes, and fig.update_xaxes(spikemode='across+marker'). Compare the generated subplot axis configuration in Plotly 4.0 with the earlier single-axis behavior. Done means identifying a supported way to make the spike line span all shared subplots, or documenting that limitation and its workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data-visualization
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.