plotly / plotly/plotly.py

add_hline not working for make_subplots if not populated

未關閉
#5,136 2 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

bug P2
主要語言
Python
星號
18.8k
分支
2.8k
平均合併
16 小時 26 分鐘
30 天內合併 PR
21

描述

Whenever you add a hline/vline to a plot it should display it at the given position. However, when the figure is made with make_subplots and is not yet populated with data, it never shows the line.

import plotly.graph_objects as go
from plotly.subplots import make_subplots

for name, fig in {
    "go.Figure": go.Figure(),
    "make_subplots": make_subplots(rows=1, cols=1)
}.items():
    fig.add_hline(y=0.5)
    # Add a trace after the line
    fig.add_trace(go.Scatter(x=[1, 2], y=[0, 1]))
    fig.update_layout(title=name)
    fig.show()

Image
Image

pip list

Package Version


asttokens 3.0.0
attrs 25.3.0
colorama 0.4.6
comm 0.2.2
debugpy 1.8.13
decorator 5.2.1
executing 2.2.0
fastjsonschema 2.21.1
ipykernel 6.29.5
ipython 9.0.2
ipython_pygments_lexers 1.1.1
jedi 0.19.2
jsonschema 4.23.0
jsonschema-specifications 2024.10.1
jupyter_client 8.6.3
jupyter_core 5.7.2
matplotlib-inline 0.1.7
narwhals 1.31.0
nbformat 5.10.4
nest-asyncio 1.6.0
packaging 24.2
parso 0.8.4
pip 24.3.1
platformdirs 4.3.7
plotly 6.0.1
prompt_toolkit 3.0.50
psutil 7.0.0
pure_eval 0.2.3
Pygments 2.19.1
python-dateutil 2.9.0.post0
pywin32 310
pyzmq 26.3.0
referencing 0.36.2
rpds-py 0.23.1
six 1.17.0
stack-data 0.6.3
tornado 6.4.2
traitlets 5.14.3
typing_extensions 4.12.2
wcwidth 0.2.13

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

研究方向

首先使用 go.Figure 和 make_subplots 執行提供的重現,重點關注 add_hline 和 add_vline 進入點,以及後續的 add_trace 呼叫。追蹤在資料存在之前 subplot domain 或 shapes 如何初始化;完成標準是:在兩種情況下加入 trace 後,線都會出現在 y=0.5,並為空的 make_subplots figure 提供回歸覆蓋。

由索引模型根據 Issue 內容生成。

評估

技術堆疊
plotly, python
領域
data-visualization
Issue 類型
缺陷
難度
3/5
預估耗時
1-2 天
活躍度
停滯
描述清晰度
基本清楚
新手友好度
45/100

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。