pyFDN.animate#
- pyFDN.animate(plot_fn, frames, *, labels=None, label_prefix='', label_format='', frame_ms=300, transition_ms=0, title=None)[source]#
Animate a sequence of frames built by any per-frame plotting function.
plot_fn(frame)is called for each entry inframesand must return a single-subplot Plotly figure (e.g.plot_matrix(),plot_impulse_response()). The traces of each figure become one animation frame; the first figure supplies the base layout (size, axes, color scale), to which a play/pause button and a slider are added.This composes with the existing
plot_*builders instead of re-deriving their styling. To animate a matrixCof shape(rows, cols, T)over time, with fixed color limits:import functools fig = pyFDN.animate( functools.partial(pyFDN.plot_matrix, zmin=-1, zmax=1), [C[:, :, k] for k in range(C.shape[2])], labels=t, label_prefix="t = ", label_format=".2f", ) fig.show()
- Parameters:
plot_fn (
Callable[[Any],Any]) – Maps oneframesentry to a Plotly figure. Usefunctools.partial()or a lambda to fix extra arguments (e.g. color limits) so every frame is built consistently.frames (
Sequence[Any]) – One argument per frame, passed positionally toplot_fn.labels (
Sequence[Any] |None) – Slider label per frame. Defaults to the frame index.label_prefix (
str) – Prefix shown before the current label (e.g."t = ").label_format (
str) – Format spec applied to each label, e.g.".2f". Empty usesstr.frame_ms (
int) – Per-frame duration in milliseconds during playback. Default 300.transition_ms (
int) – Tween duration between frames in milliseconds. Default 0.title (
str|None) – Figure title. If None, the first frame’s title is kept.
- Returns:
Call
.show()to display.- Return type: