Skip to content

Add animation example in the docs #466

@nvaytet

Description

@nvaytet

In the "Custom figures" section, we should add an example on how to make animations with Plopp, based on MPL's animation functionality.

The example would be something like

import plopp as pp
import matplotlib.animation as animation

# Some 3d data
da = pp.data.data3d()

data_node = pp.Node(da)
index_node = pp.Node(0)
# Here, 'z' is the dimension you want to slice
slice_node = pp.Node(lambda da, ind: da['z', ind], da=data_node, ind=index_node)

f = pp.imagefigure(slice_node, cbar=True)

def update(frame):
    index_node.func = lambda: frame
    index_node.notify_children('')

ani = animation.FuncAnimation(fig=f.fig, func=update, frames=30, interval=30)
ani.save(filename="html_example.html", writer="html")

but would be nice with some more interesting data (maybe the three_bands data from the plopp.data.examples?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions