plotly / plotly/plotly.py

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

未关闭
#3,424 0 条评论 1 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

bug P3
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
16 小时 26 分钟
30 天内合并 PR
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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

复现 issue 中的 5 x 3 图表与表格混合布局,然后添加所示的 fig.add_vline 调用,并将其与正常工作的情况进行比较。首先跟踪 make_subplots 以及 Table 子图周围对 hline/vline 的处理。完成标准是:hline 和 vline 都能为图表子图渲染,且不会因 Table trace 引发 PlotlyKeyError。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
data-visualization
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。