plotly / plotly/plotly.py

make the `._has_subplots` method from `go.Figure` accessible

未关闭
#4,062 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

feature P3
主要语言
Python
星标
18.8k
派生
2.8k
平均合并
16 小时 26 分钟
30 天内合并 PR
21

描述

In some cases, when writings callbacks that only update a subplot of a Figure, it is useful to know if the figure will accept an append_trace to a specific location, or if add_trace should be used instead.

I use this workaround (using a try/except isn't great):

    if fig._has_subplots():
        fig.append_trace(trace, 1, 1)
    else:
        _ = fig.add_trace(trace)

If I only use fig.append_trace(trace, 1, 1), I get Exception: In order to reference traces by row and column, you must first use plotly.tools.make_subplots to create the figure with a subplot grid.

If I only use fig.add_trace(trace), the layout gets messed up.

Could it be possible to make this method public?

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

检查 go.Figure 的 _has_subplots 实现,以及围绕 append_trace、add_trace 和 make_subplots 的公开 Figure API。当调用方可以使用公开检查来确定行和列 trace 引用是否有效,而无需依赖 try/except 变通方案,同时保留现有的 subplot 行为时,这项工作就完成了。

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

评估

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

把新 issue 发到你的邮箱

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