plotly / plotly/plotly.py

mixed graph and table subplots break when hline or vline are added

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

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

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

説明

Describe your context
Python 3.8
Dash 2.0
Plotly 5.3.1

  • replace the result of pip list | grep dash below
dash                                              2.0.0
dash-core-components                              2.0.0
dash-html-components                              2.0.0
dash-table                                        5.0.0

Take a 5 x 3 subplot layout as follows:

    fig = make_subplots(rows=5, cols=3,
                        specs=[[{'secondary_y': True}, {'secondary_y': False}, {'type': 'table'}],
                               [{'secondary_y': False}, {'secondary_y': False}, {'secondary_y': False}],
                               [{'secondary_y': False}, {'secondary_y': False}, {'secondary_y': False}],
                               [{'secondary_y': False}, {'secondary_y': False}, {'secondary_y': False}],
                               [{'secondary_y': False}, {'secondary_y': False}, {'secondary_y': False}]],
                        shared_xaxes=True, shared_yaxes=True,
                        vertical_spacing=0.01, horizontal_spacing=0,
                        row_heights=[0.775, 0.15, 0.025, 0.025, 0.025], column_widths=[0.8, 0.1, 0.1])

We add subplots as follows:

fig.add_trace(go.Scatter(x= ... row=1, col=1)
fig.add_trace(go.Scatter(x= ... row=1, col=2)
fig.add_trace(go.Scatter(x= ... row=2, col=1)
fig.add_trace(go.Scatter(x= ... row=3, col=1)
fig.add_trace(go.Scatter(x= ... row=4, col=1)
fig.add_trace(go.Scatter(x= ... row=5, col=1)

At position row=1 col=3 we place a table.

fig.add_trace(go.Table(header=dict(line=dict(color='red'),
                              fill=dict(color='red')),
                       cells=dict(values=[df.A, df.B])),
              row=1, col=3)

This all works fine. But when we add an hline or vline to the top left graph...

        fig.add_vline(x=42, line_width=1, line_dash='dot', line_color='rgba(255, 165, 0, 0.3)', row=1, col=1)

Plotly throws an error:

_plotly_utils.exceptions.PlotlyKeyError: Invalid property specified for object of type plotly.graph_objs.Table: 'xaxis'

Did you mean "cells"?

This happens regardless of line orientation (h or v), or if the lines are limited to a single row and col or spanning all cols.

Posting in in case this may be a bug.
Posted also on StackOverflow, where Rob Raymond prepared a working example and also a workaround for this issue.
See here:
https://stackoverflow.com/questions/69498665/why-do-plotly-dash-mixed-graph-and-table-subplots-break-when-hline-or-vline-ar/69507165#69507165

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

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

はじめの一歩

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

調査の方向性

issue にある 5 x 3 のグラフとテーブルの混在レイアウトを再現し、次に示されている fig.add_vline 呼び出しを追加して、動作するケースと比較します。まず、Table サブプロット周辺の make_subplots と hline/vline の処理を追跡します。hline と vline の両方がグラフのサブプロットに対して、Table trace による PlotlyKeyError を発生させずに描画されれば完了です。

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

評価

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

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

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