plotly / plotly/plotly.py

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

オープン
#5,427 コメント 9 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P3
主要言語
Python
スター
18.8k
フォーク
2.8k
平均マージ
16時間 26分
マージ済み PR(30日)
21

説明

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.

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、shared_xaxes=True と設定済みの spike-line オプションを使って、提供された make_subplots() の例を再現します。subplot x-axes と hover の動作がどのように表現されているかを追跡し、その後、変更を加える前に関連する実装とテストを特定します。完了条件は、任意の subplot にホバーすると、レイアウトを壊すことなく、すべての subplot にまたがって位置の揃った垂直の spike-line が表示されることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
pandas, python
領域
data-visualization
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
静か
明瞭さ
おおむね明確
初心者へのやさしさ
48/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。