在Plotly中设置散点GL图形的动画

2024-06-16 13:51:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试在Plotly中设置散点图的几个帧的动画。我可以使用ScatterGL显示单个绘图,但当我尝试为绘图设置动画时,会出现以下错误:

Uncaught TypeError: r[d] is undefined
    exports http://127.0.0.1:61355/:65
    d http://127.0.0.1:61355/:65
    plot http://127.0.0.1:61355/:65
    drawData http://127.0.0.1:61355/:65
    syncOrAsync http://127.0.0.1:61355/:65
    plot http://127.0.0.1:61355/:65
    call http://127.0.0.1:61355/:65
    layoutReplot http://127.0.0.1:61355/:65
    syncOrAsync http://127.0.0.1:61355/:65
    q http://127.0.0.1:61355/:65
    call http://127.0.0.1:61355/:65
    _redrawTimer http://127.0.0.1:61355/:65

这是我的基线重现性示例:

import numpy as np
import plotly.graph_objects as go

N = 10
fig = go.Figure(
    data=[
        go.Scattergl(
            x=np.random.randn(N),
            y=np.random.randn(N),
            mode="markers",
            marker=dict(size=4, colorbar=dict(thickness=30, ypad=80),),
        )
    ],
    layout=go.Layout(
        title="Start Title",
        updatemenus=[
            dict(
                type="buttons",
                buttons=[dict(label="Play", method="animate", args=[None])],
            )
        ],
    ),
    frames=[
        go.Frame(
            data=[
                go.Scattergl(
                    x=np.random.randn(N),
                    y=np.random.randn(N),
                    mode="markers",
                    marker=dict(size=4, colorbar=dict(thickness=30, ypad=80),),
                )
            ]
        ),
    ],
)

fig.show()

我做错什么了吗?还是说ScatterGL不具备动画功能


Tags: importhttpgo绘图plotasnpfig