plotly / plotly/plotly.py

Using a slider creates jitter on an animated scattermapbox

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

还没有人认领这个 Issue。

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

描述

An animated scattermapbox figure with a legend sometimes shows jitter while using a slider.

import plotly.graph_objects as go


lats = [_*0.02 for _ in range(500)]
lons = [0]*500

fig = go.Figure()
fig.add_trace(go.Scattermapbox(lat=[0], lon=[0], visible="legendonly"))
fig.add_trace(go.Scattermapbox(lat=[0], lon=[0], showlegend=False))

frames = []

for lat, lon in zip(lats, lons):
    frame = go.Frame(data=go.Scattermapbox(lat=[lat], lon=[lon]),
                     traces=[1], name=str(lat))
    frames.append(frame)

fig.update(frames=frames)

fig.layout.mapbox.center = {"lat": 5, "lon": 0}
fig.layout.mapbox.style = "open-street-map"
fig.layout.mapbox.zoom = 4


def frame_args(duration):
    template = {"frame": {"duration": duration},
                "mode": "immediate",
                "fromcurrent": True,
                "transition": {"duration": 0}}
    return template


def step_dict(frame):
    template = {"args": [[frame.name], frame_args(0)],
                "label": frame.name,
                "method": "animate"}
    return template

steps = [step_dict(f) for f in fig.frames]

sliders = [{"steps": steps}]

fig.update_layout(sliders=sliders)

fig.show()

https://user-images.githubusercontent.com/9297904/148424735-cb11c162-ad21-437f-afc7-55447c06d659.mov

贡献指南

打开贡献指南

从这里开始

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

调研方向

首先运行提供的 Python 重现代码,并在移动滑块时观察动画 scattermapbox。从生成的 figure 入手,追踪滑块和 frame-animation 的处理;当同一个带图例的 figure 在使用滑块时不再出现 jitter 时,即表示完成。issue 中没有指定源文件或测试。

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

评估

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

把新 issue 发到你的邮箱

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