Skip to content

Using a slider creates jitter on an animated scattermapbox #3539

Open
@kdpenner

Description

@kdpenner

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()
Screen.Recording.2022-01-06.at.11.54.41.AM.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3backlogbugsomething brokenperformancesomething is slow

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions