Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/source/api/plotting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ Plotting
:members:
:no-private-members:
:no-special-members:

Animations
----------

.. autoapimodule:: animation
:members:
:no-private-members:
:no-special-members:
45 changes: 45 additions & 0 deletions notebooks/user_guide.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -4868,6 +4868,51 @@
"plt.show()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Animate trajectories and Voronoi cells\n",
"\n",
"In Jupyter notebooks, `animate_trajectories` and `animate_voronoi_cells` render interactive frame-by-frame animations directly inline (`pip install pedpy[notebook]`).\n",
"You can color pedestrians or Voronoi cells by any per-frame analysis result (such as individual speed or Voronoi density) and step frames via `every_nth_frame`:\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pedpy import SPEED_COL, animate_trajectories\n",
"\n",
"animate_trajectories(\n",
" traj=traj[500:550],\n",
" walkable_area=walkable_area,\n",
" color_data=individual_speed_single_sided,\n",
" color_column=SPEED_COL,\n",
" every_nth_frame=5,\n",
" marker_size=25,\n",
")"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"from pedpy import DENSITY_COL, animate_voronoi_cells\n",
"\n",
"animate_voronoi_cells(\n",
" voronoi_data=individual[individual.frame.between(500, 550)],\n",
" traj=traj[500:550],\n",
" walkable_area=walkable_area,\n",
" color_column=DENSITY_COL,\n",
" every_nth_frame=10,\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {
Expand Down
6 changes: 6 additions & 0 deletions pedpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@
compute_species,
compute_voronoi_speed,
)
from .plotting.animation import (
animate_trajectories,
animate_voronoi_cells,
)
from .plotting.plotting import (
PEDPY_BLUE,
PEDPY_GREEN,
Expand Down Expand Up @@ -241,6 +245,8 @@
"plot_voronoi_cells",
"plot_walkable_area",
"plot_acceleration",
"animate_trajectories",
"animate_voronoi_cells",
"ID_COL",
"FRAME_COL",
"X_COL",
Expand Down
Loading