Bug: `make_subplots()` doesn't use shared x-axes for traces on different subplots, even when `shared_xaxes` is set to True
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Python
- Sterne
- 18.8k
- Forks
- 2.8k
- Ø Merge
- 16 Std. 26 Min.
- Gemergte PRs (30 T.)
- 21
Beschreibung
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
hovermode='x unified'- Only unifies hover labels, not spike linesfig.update_traces(xaxis='x')- Shows spikes across all subplots but breaks subplot layout (all data gets squeezed into first subplot's x-axis range)- Various combinations of
spikemode,spikesnap, andmatches='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.
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, das bereitgestellte make_subplots()-Beispiel mit shared_xaxes=True und den konfigurierten Spike-Line-Optionen zu reproduzieren. Verfolge, wie subplot x-axes und das Hover-Verhalten dargestellt werden, und ermittle dann die relevante Implementierung und die Tests, bevor du sie änderst. Als erledigt gilt die Aufgabe, wenn beim Hovern über einen beliebigen Subplot eine ausgerichtete vertikale Spike-Line über alle Subplots hinweg angezeigt wird, ohne deren Layout zu beeinträchtigen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- pandas, python
- Bereich
- data-visualization
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100