go.Contour doesn't render correctly in animation frames when multiple traces are present
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 42/100
- Issue 類型
- 缺陷
- 描述清晰度
- 基本清楚
- 活躍度
- 停滯
- 技術堆疊
- python
研究方向
首先執行 plotly.py 中提供的最小 Python 範例,並比較僅使用 go.Contour 的動畫與包含額外 go.Scatter 軌跡的動畫。追蹤 Figure 和 Frame 用於等高線資料的動畫/繪製路徑;完成的標準是:存在多個軌跡時,等高線在所有影格中都能正確繪製,同時不影響單一軌跡的情況。
由索引模型根據 Issue 內容生成。
描述
I'm encountering an issue with plotly.graph_objects.Figure animations. When using go.Contour inside go.Frame along with additional traces such as go.Scatter, the contour plot no longer renders correctly during animation. However, if I only include the go.Contour trace by itself in each frame, it animates perfectly.
Here's a minimal reproducible example:
import plotly.io as pio
pio.renderers.default = 'browser'
import plotly.graph_objects as go
import numpy as np
z_base = np.array([
[10, 10.625, 12.5, 15.625, 20],
[5.625, 6.25, 8.125, 11.25, 15.625],
[2.5, 3.125, 5., 8.125, 12.5],
[0.625, 1.25, 3.125, 6.25, 10.625],
[0, 0.625, 2.5, 5.625, 10]
])
lk_x=[0,0,1,1,0]
lk_y=[0,1,1,0,0]
data_line = go.Scatter(x=lk_x, y=lk_y, mode='lines', fill='toself', fillcolor='rgba(60, 53, 48, 0.5)', line_color='black', showlegend=False)
scales = np.linspace(0.2, 1.0, 10)
frames = []
for i, s in enumerate(scales):
z_scaled = z_base * s
frames.append(go.Frame(
data=[
go.Contour(
z=z_scaled,
colorbar=dict(
thickness=25,
thicknessmode='pixels',
len=0.6,
lenmode='fraction',
outlinewidth=0
)
,zorder=2
),
go.Scatter(
x=[0, 1, 2, 3, 4],
y=[0, 1, 1.5, 2, 3],
mode='lines',
line=dict(color='black', width=2),
showlegend=False,
zorder=0
),
data_line
],
name=f"scale_{i}"
))
fig = go.Figure(
data=frames[0].data,
frames=frames
)
fig.update_layout(
title="Contour",
updatemenus=[{
"buttons": [
{"label": "play", "method": "animate", "args": [None, {"frame": {"duration": 500}, "fromcurrent": True}]},
{"label": "pause", "method": "animate", "args": [[None], {"mode": "immediate", "frame": {"duration": 0}}]}
],
"type": "buttons",
"showactive": True,
"x": 0.1,
"y": -0.1
}],
sliders=[{
"steps": [{"args": [[f.name]], "label": f"Step {i+1}", "method": "animate"} for i, f in enumerate(frames)],
"x": 0.1,
"len": 0.9
}],
width=500,
height=500
)
fig.show()
only include the go.Contour trace:
with additional traces:
- 主要語言
- Python
- 星號
- 18.8k
- 分支
- 2.8k
- 平均合併
- 13 小時 28 分鐘
- 30 天內合併 PR
- 20
貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
plotly/plotly.py 的其他 Issue
-
P3 size: 1 task
難度 2/5 1-3 小時 新手友好度 65/100
-
P3 size: 1 task
難度 2/5 1-3 小時 新手友好度 72/100
-
bug P1
難度 1/5 1 小時以內 新手友好度 68/100
-
feature P3
難度 2/5 1-3 小時 新手友好度 62/100
-
feature P3
難度 2/5 1-3 小時 新手友好度 72/100
相似的 Issue
-
難度 1/5 1 小時以內 新手友好度 75/100
-
hcocena 未關閉policies-accepted pre-review precheck-passed
難度 1/5 1 小時以內 新手友好度 88/100
Bioconductor/BiocContributions#214 · 5 則留言 ·
-
難度 1/5 1 小時以內 新手友好度 92/100
TencentCloud/Octop#1169 · 1 則留言 ·
-
難度 2/5 1-3 小時 新手友好度 70/100
521xueweihan/HelloGitHub#3778 ·
-
The version checker's trailing attribute region has no control for a less-than inside a quoted value 未關閉area: dashboard area: tests bug perceived difficulty: 2 python
難度 2/5 1-3 小時 新手友好度 84/100
Nitjsefnie-Harness-Commons/daedalus#1105 · 1 則留言 ·