Skip to content

Add animation functions for trajectories and Voronoi cells in Jupyter notebooks #550

Description

@schroedtert

Summary

Add animate_trajectories and animate_voronoi_cells functions to PedPy that render frame-by-frame animations of pedestrian data directly in Jupyter notebooks.

Background / Context

PedPy currently supports static trajectory and Voronoi plots but has no animation capability. Animating pedestrian movement over time is a core analysis and presentation need for users working in notebook-based workflows. This is a frequently requested feature.

Technical Details

  • Animations should be based on matplotlib.animation.FuncAnimation and rendered in notebooks via IPython.display.HTML
  • Interface should align with existing plot_trajectories for parameter naming consistency (e.g. traj, walkable_area, color_data, color_column, cmap)
  • IPython should be an optional dependency with a descriptive error when called outside a notebook environment
  • New functions belong in pedpy/plotting/

Acceptance Criteria

  • Usage is demonstrated in the user guide notebook
  • IPython is listed as an optional dependency with a descriptive error when missing

Activity

  1. added this to the v1.6.0 milestone on Jun 28, 2026
  2. added
    documentation
    usability
    on Jun 28, 2026
  3. mirakuepper commented on Nov 5, 2026

    @mirakuepper

    I would really appreciate that feature!
    Besides being able to animate the trajectories (e.g as points with adjustable size), a third column of the data, e.g. speed but also some other result of the analysis, should be usable as color for the animated trajectory points.
    That would be a great feature to have a (quick) overview of the analysis without beeing forced to save all frames as files and create a video out of that.

  4. M-Colley commented on Nov 21, 2026

    @M-Colley

    Opened #596 implementing animate_trajectories and animate_voronoi_cells in pedpy.plotting.animation (and exported directly from pedpy).

    In particular, addressing @mirakuepper's point above:

    • Adjustable point size: animate_trajectories supports marker_size (and traj_frame_marker_size for consistency with plot_trajectories).
    • Coloring by any scalar column or analysis DataFrame: You can either pass a separate per-frame DataFrame via color_data=individual_speed, color_column=SPEED_COL (or omit color_column when color_data has a single value column) or reference an extra column already present in traj.data via color_column=..., with configurable cmap, vmin, vmax, and colorbar label.
    • Notebook & script support: In Jupyter notebooks (pip install pedpy[notebook]), as_html=True (default) renders an interactive JSHTML player inline; outside notebooks, as_html=False returns the matplotlib.animation.FuncAnimation object directly.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationusability

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions