Bug: `make_subplots()` doesn't use shared x-axes for traces on different subplots, even when `shared_xaxes` is set to True

Aperta
#5,427 9 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
pandas, python

Direzione di ricerca

Inizia riproducendo l’esempio fornito di make_subplots() con shared_xaxes=True e le opzioni di spike-line configurate. Traccia il modo in cui sono rappresentati i subplot x-axes e il comportamento di hover, quindi individua l’implementazione e i test pertinenti prima di modificarli. Il lavoro è completato quando, passando il mouse su un qualsiasi subplot, viene mostrata una spike-line verticale allineata su tutti i subplot senza compromettere il loro layout.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug P3

Description

When using make_subplots() with shared_xaxes=True, spike lines only appear on the subplot where the cursor is hovering, rather than showing across all subplots simultaneously.

Expected Behavior

When hovering over any subplot, a vertical spike line should appear at the same x-position across all subplots, similar to the behavior in TradingView or other financial charting tools.

Current Behavior

The spike line only appears on the subplot currently under the cursor. When moving to a different subplot, the spike line moves with the cursor instead of showing on all subplots.

Code Example

import plotly.graph_objects as go
from plotly.subplots import make_subplots
import pandas as pd

# Create sample data
df = pd.DataFrame({
    'x': pd.date_range('2024-01-01', periods=100),
    'y1': range(100),
    'y2': [x**2 for x in range(100)]
})

# Create subplots
fig = make_subplots(
    rows=2, cols=1,
    shared_xaxes=True,
    vertical_spacing=0.02
)

fig.add_trace(go.Scatter(x=df['x'], y=df['y1'], name='Line 1'), row=1, col=1)
fig.add_trace(go.Scatter(x=df['x'], y=df['y2'], name='Line 2'), row=2, col=1)

fig.update_xaxes(
    showspikes=True,
    spikemode='across',
    spikesnap='cursor',
    spikecolor='black',
    spikethickness=1
)

fig.update_layout(hovermode='x unified')
fig.show()

What I've Tried

  1. hovermode='x unified' - Only unifies hover labels, not spike lines
  2. fig.update_traces(xaxis='x') - Shows spikes across all subplots but breaks subplot layout (all data gets squeezed into first subplot's x-axis range)
  3. Various combinations of spikemode, spikesnap, and matches='x' - No effect

Use Case

This feature is critical for financial/trading dashboards where users need to compare multiple indicators (price, volume, RSI, MACD, etc.) at the same point in time across multiple subplots.

Lingua principale
Python
Stelle
18.8k
Fork
2.8k
Merge medio
16h 26m
PR unite (30g)
21

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di plotly/plotly.py

Tutte le issue di plotly/plotly.py

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.