`groupclick="toggleitem"` Does Not Work Consistently Across Subplots in Plotly
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 18.8k
- フォーク
- 2.8k
- 平均マージ
- 16時間 26分
- マージ済み PR(30日)
- 21
説明
Description
When using the groupclick="toggleitem" parameter in Plotly with subplots, the toggling behavior for legend items only applies to traces in the first subplot. Traces in other subplots are not affected as expected, even when the legendgroup attribute is set consistently for all relevant traces.
This issue breaks the intended behavior of groupclick="toggleitem" for figures with subplots, where users would expect the toggling of a legend item to apply uniformly across all traces in the same legendgroup, regardless of their subplot.
Expected Behavior
Clicking a legend item with groupclick="toggleitem" should toggle the visibility of all traces in the corresponding legendgroup, including traces in subplots other than the first.
Observed Behavior
When clicking a legend item:
-
The visibility of traces is toggled only in the first subplot.
-
Traces in other subplots within the same
legendgroupremain unaffected.
Minimal Reproducible Example
import plotly.graph_objects as go
from plotly.subplots import make_subplots
# Create a subplot figure
fig = make_subplots(rows=3, cols=1)
# Add traces to the first subplot
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[1, 4, 9], name="Group A", legendgroup="group_a"), row=1, col=1)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[2, 4, 8], name="Group B", legendgroup="group_b"), row=1, col=1)
# Add traces to the second subplot
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[1, 3, 6], name="Group A", legendgroup="group_a", showlegend=False), row=2, col=1)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[2, 5, 7], name="Group B", legendgroup="group_b", showlegend=False), row=2, col=1)
# Add traces to the third subplot
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[1, 2, 3], name="Group A", legendgroup="group_a", showlegend=False), row=3, col=1)
fig.add_trace(go.Scatter(x=[1, 2, 3], y=[3, 5, 9], name="Group B", legendgroup="group_b", showlegend=False), row=3, col=1)
# Update layout with groupclick parameter
fig.update_layout(
legend=dict(groupclick="toggleitem")
)
fig.show()
Steps to Reproduce
-
Run the provided example code.
-
Click on a legend item for "Group A" or "Group B."
-
Observe that the traces in the first subplot toggle visibility as expected.
-
Notice that traces in other subplots do not toggle visibility.
### Environment
Plotly Version: 5.24.1
Python Version: 3.11.9
Operating System: Windows 11
Browser: Edge 131.0.2903.86
Additional Notes
The issue does not occur when the groupclick parameter is omitted. The default behavior works as expected, where clicking a legend item toggles all traces in the same legendgroup across all subplots.
However, groupclick="toggleitem" is necessary for more granular control of legend interactions, and it should work consistently across subplots.
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
まず、提供された Plotly 5.24.1 を使用する Python の最小再現可能例を実行し、3 つすべてのサブプロットで凡例の動作を確認します。リポジトリまたはその Plotly.js 統合における凡例インタラクションのエントリポイントを追跡し、次に共有された凡例グループでの groupclick="toggleitem" のカバレッジを追加します。凡例項目をクリックすると、すべてのサブプロットで期待される可視性の変更が一貫して適用されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- data-visualization
- issue の種類
- バグ
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 52/100