Plotting#

Module containing plotting functionalities.

PEDPY_BLUE#
PEDPY_ORANGE#
PEDPY_GREEN#
PEDPY_PETROL#
PEDPY_GREY#
PEDPY_RED#
plot_speed_at_line(*, speed_at_line, axes=None, **kwargs)#

Plot the speed of both species and the total speed at the line.

Parameters:
  • speed_at_line (pd.DataFrame) – DataFrame containing information on speed at the line

  • axes (matplotlib.axes.Axes, optional) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • title (optional) – title of the plot

  • color_species1 (optional) – color of the speed of species 1 in the plot

  • color_species2 (optional) – color of the speed of species 2 in the plot

  • color_total (optional) – color of the total speed in the plot

  • label_species1 (optional) – tag of species 1 in the legend

  • label_species2 (optional) – tag of species 2 in the legend

  • label_total (optional) – tag of total speed in the legend

  • line_width (optional) – line width of the density timeseries

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

  • x_axis (optional) – chose whether the ‘frame’ (default) or ‘time’ is plotted on the x-axis

  • framerate (optional) – give the framerate, when x-axis==’time’

Returns:

matplotlib.axes.Axes instance where the speeds are plotted

Return type:

matplotlib.axes.Axes

plot_density_at_line(*, density_at_line, axes=None, **kwargs)#

Plot the density of both species and the total density at the line.

Parameters:
  • density_at_line (pd.DataFrame) – DataFrame containing information on density at the line

  • axes (matplotlib.axes.Axes, optional) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • title (optional) – title of the plot

  • color_species1 (optional) – color of the density of species 1 in the plot

  • color_species2 (optional) – color of the density of species 2 in the plot

  • color_total (optional) – color of the total density in the plot

  • label_species1 (optional) – tag of species 1 in the legend

  • label_species2 (optional) – tag of species 2 in the legend

  • label_total (optional) – tag of total speed in the legend

  • line_width (optional) – line width of the density timeseries

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

  • x_axis (optional) – chose whether the ‘frame’ (default) or ‘time’ is plotted on the x-axis

  • framerate (optional) – give the framerate, when x-axis==’time’

Returns:

matplotlib.axes.Axes instance where the densities are plotted

Return type:

matplotlib.axes.Axes

plot_flow_at_line(*, flow_at_line, axes=None, **kwargs)#

Plot the flow of both species and the total flow at the line.

Parameters:
  • flow_at_line (pd.DataFrame) – DataFrame containing information on flow at the line

  • axes (matplotlib.axes.Axes, optional) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • title (optional) – title of the plot

  • color_species1 (optional) – color of the flow of species 1 in the plot

  • color_species2 (optional) – color of the flow of species 2 in the plot

  • color_total (optional) – color of the total flow in the plot

  • label_species1 (optional) – tag of species 1 in the legend

  • label_species2 (optional) – tag of species 2 in the legend

  • label_total (optional) – tag of total speed in the legend

  • line_width (optional) – line width of the density timeseries

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

  • x_axis (optional) – chose whether the ‘frame’ (default) or ‘time’ is plotted on the x-axis

  • framerate (optional) – give the framerate, when x-axis==’time’

Returns:

matplotlib.axes.Axes instance where the profiles are plotted

Return type:

matplotlib.axes.Axes

plot_nt(*, nt, axes=None, **kwargs)#

Plot the number of pedestrians crossing a line over time.

Parameters:
  • nt (pd.DataFrame) – cumulative number of pedestrians over time

  • axes (matplotlib.axes.Axes) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • color (optional) – color of the plot

  • title (optional) – title of the plot

  • line_width (optional) – line width of the N-t diagram

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

Returns:

matplotlib.axes.Axes instance where the number of pedestrians is plotted

Return type:

matplotlib.axes.Axes

plot_density(*, density, axes=None, **kwargs)#

Plot the density over time.

Parameters:
  • density (pd.DataFrame) – density per frame

  • axes (matplotlib.axes.Axes) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • color (optional) – color of the plot

  • title (optional) – title of the plot

  • x_axis (optional) – chose whether the ‘frame’ (default) or ‘time’ is plotted on the x-axis

  • framerate (optional) – give the framerate, when x-axis==’time’

  • line_width (optional) – line width of the density timeseries

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

Returns:

matplotlib.axes.Axes instance where the density is plotted

Return type:

matplotlib.axes.Axes

plot_speed(*, speed, axes=None, **kwargs)#

Plot the speed over time.

Parameters:
  • speed (pd.Series) – speed per frame

  • axes (matplotlib.axes.Axes) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • color (optional) – color of the plot

  • line_width (optional) – line width of the speed timeseries

  • title (optional) – title of the plot

  • x_axis (optional) – chose whether the ‘frame’ (default) or ‘time’ is plotted on the x-axis

  • framerate (optional) – give the framerate, when x-axis==’time’

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

Returns:

matplotlib.axes.Axes instance where the density is plotted

Return type:

matplotlib.axes.Axes

plot_speed_distribution(*, speed, axes=None, **kwargs)#

Plot the speed distribution as violin plot.

Parameters:
  • speed (pd.DataFrame) – speed of the pedestrians

  • axes (matplotlib.axes.Axes) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • facecolor (optional) – color of the plot body

  • edgecolor (optional) – color of the edges of the plot

  • title (optional) – title of the plot

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

Returns:

matplotlib.axes.Axes instance where the density is plotted

Return type:

matplotlib.axes.Axes

plot_density_distribution(*, density, axes=None, **kwargs)#

Plot the density distribution as violin plot.

Parameters:
  • density (pd.DataFrame) – individual density of the pedestrian

  • axes (matplotlib.axes.Axes) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • facecolor (optional) – color of the plot body

  • edgecolor (optional) – color of the edges of the plot

  • title (optional) – title of the plot

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

Returns:

matplotlib.axes.Axes instance where the density is plotted

Return type:

matplotlib.axes.Axes

plot_crossing_speed_flow(*, flow, axes=None, **kwargs)#

Plot the relationship of mean speed and flow while crossing a measurement line.

Parameters:
  • flow (pd.DataFrame) – flow for some given crossing_frames and nt

  • axes (matplotlib.axes.Axes) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • color (optional) – color of the plot

  • title (optional) – title of the plot

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

  • marker (optional) – Markerstyle

  • marker_size (optional) – Size of the markers

Returns:

matplotlib.axes.Axes instance where the flow is plotted

Return type:

matplotlib.axes.Axes

plot_acceleration(*, acceleration, axes=None, **kwargs)#

Plot the acceleration over time.

Parameters:
  • acceleration (pd.Series) – acceleration per frame

  • axes (matplotlib.axes.Axes) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • color (optional) – color of the plot

  • line_width (optional) – line width of the acceleration time series

  • title (optional) – title of the plot

  • x_axis (optional) – chose whether the ‘frame’ (default) or ‘time’ is plotted on the x-axis

  • framerate (optional) – give the framerate, when x-axis==’time’

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

Returns:

matplotlib.axes.Axes instance where the density is plotted

Return type:

matplotlib.axes.Axes

plot_neighborhood(*, pedestrian_id, neighbors, frame, voronoi_data, walkable_area=None, axes=None, **kwargs)#

Plots the neighborhood of a specified pedestrian.

This function visualizes the neighborhood for a given pedestrian at a specified frame using Voronoi polygons for each pedestrian. It colors the specified pedestrian, their neighbors, and other pedestrians distinctly based on the neighborhood data.

Parameters:
  • pedestrian_id (int) – id of pedestrian to plot neighbors for

  • neighbors (pd.DataFrame) – neighborhood data based on the Voronoi cells

  • frame (int) – frame for which the plot is created

  • voronoi_data (pd.DataFrame) – individual Voronoi polygon for each person and frame

  • walkable_area (WalkableArea) – WalkableArea object of plot

  • axes (matplotlib.axes.Axes) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • base_color (optional) – color of the base pedestrian, whose neighborhood will be highlighted

  • base_alpha (optional) – alpha of the base pedestrian

  • neighbor_color (optional) – color of neighbor pedestrians of the base pedestrian

  • neighbor_alpha (optional) – alpha of the neighbor pedestrians

  • default_color (optional) – color of default pedestrians, which are not neighbors of the base pedestrian

  • default_alpha (optional) – alpha of the default pedestrians

  • border_line_color (optional) – color of the borders

  • border_line_width (optional) – line width of the borders

  • hole_color (optional) – background color of holes

  • hole_alpha (optional) – alpha of background color for holes

  • title (optional) – title of the plot

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

Returns:

instances where the neighborhood is plotted

Return type:

matplotlib.axes.Axes

plot_time_distance(*, time_distance, speed=None, axes=None, **kwargs)#

Plots the time to reach a target over distance.

If a speed DataFrame is provided, lines will be colored according to speed values.

Parameters:
  • time_distance (pd.DataFrame) – DataFrame containing information on time and distance to some target

  • speed (pd.DataFrame, optional) – DataFrame containing speed calculation.

  • axes (matplotlib.axes.Axes) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • marker_color (optional) – color of the markers on the plot

  • marker_size (optional) – size of the markers

  • marker (optional) – type of the markers

  • line_color (optional) – color of the lines on the plot

  • line_width (optional) – width of the line sof the plot

  • line_alpha (optional) – alpha value of the plotted lines

  • title (optional) – title of the plot

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

Returns:

matplotlib.axes.Axes instance where the distance is plotted

Return type:

matplotlib.axes.Axes

plot_profiles(*, walkable_area, measurement_area=None, profiles, axes=None, **kwargs)#

Plot the mean of the profiles.

Parameters:
  • walkable_area (WalkableArea) – walkable area of the plot

  • measurement_area (MeasurementArea) – Measurement area for which the profiles are computed.

  • profiles (list) – List of profiles like speed or density profiles

  • axes (matplotlib.axes.Axes) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • title (optional) – title of the plot

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

  • walkable_color (optional) – color of the walkable area in the plot

  • hole_color (optional) – background color of holes

  • hole_alpha (optional) – alpha of background color for holes

Returns:

matplotlib.axes.Axes instance where the profiles are plotted

Return type:

matplotlib.axes.Axes

plot_rset_map(*, walkable_area, rset_map, measurement_area=None, axes=None, **kwargs)#

Plot an RSET (Required Safe Egress Time) map.

Parameters:
  • walkable_area (WalkableArea) – walkable area of the plot

  • rset_map (numpy.typing.NDArray[numpy.float64]) – 2-D array as returned by compute_rset_map()

  • measurement_area (AxisAlignedMeasurementArea) – measurement area used when computing the RSET map (optional)

  • axes (matplotlib.axes.Axes) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance

Keyword Arguments:
  • title (optional) – title of the plot

  • cmap (optional) – colormap (default "jet")

  • vmin (optional) – minimum value for the colormap

  • vmax (optional) – maximum value for the colormap

  • label (optional) – colorbar label (default "time / s")

  • font_size (optional) – font size for axis and colorbar labels (default 14)

  • title_size (optional) – font size for the title (default 16)

  • tick_size (optional) – font size for tick labels (default 12)

  • walkable_color (optional) – color of the walkable area border

  • hole_color (optional) – background color of holes

  • hole_alpha (optional) – alpha of background color for holes

Returns:

matplotlib.axes.Axes instance where the RSET map is plotted

Return type:

matplotlib.axes.Axes

plot_walkable_area(*, walkable_area, axes=None, **kwargs)#

Plot the given walkable area in 2-D.

Parameters:
  • walkable_area (WalkableArea) – WalkableArea object to plot

  • axes (matplotlib.axes.Axes) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • border_line_color (optional) – color of the lines of the borders

  • border_line_width (optional) – line width of the borders

  • hole_color (optional) – background color of holes

  • hole_alpha (optional) – alpha of background color for holes

  • title (optional) – title of the plot

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

Returns:

matplotlib.axes.Axes instance where the walkable area is plotted

Return type:

matplotlib.axes.Axes

plot_trajectories(*, traj, walkable_area=None, axes=None, **kwargs)#

Plot the given trajectory and walkable area in 2-D.

Parameters:
  • traj (TrajectoryData) – Trajectory object to plot

  • walkable_area (WalkableArea, optional) – WalkableArea object to plot

  • axes (matplotlib.axes.Axes, optional) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • traj_color (optional) – color of the trajectories

  • traj_width (optional) – width of the trajectories

  • traj_alpha (optional) – alpha of the trajectories

  • traj_start_marker (optional) – marker to indicate the start of the trajectory

  • traj_start_color (optional) – color of the start marker, defaults to traj_color if not set

  • traj_start_marker_alpha (optional) – alpha of the start marker, defaults to 1.0

  • traj_end_marker (optional) – marker to indicate the end of the trajectory

  • traj_end_color (optional) – color of the end marker, defaults to traj_color if not set

  • traj_end_marker_alpha (optional) – alpha of the end marker, defaults to 1.0

  • traj_start_marker_size (optional) – size of the start marker, defaults to None if not set (markers will be sized automatically by matplotlib)

  • traj_end_marker_size (optional) – size of the end marker, defaults to None if not set

  • traj_frame (optional) – frame number at which to plot a position marker for each pedestrian

  • traj_frame_marker (optional) – marker style for the frame position markers

  • traj_frame_color (optional) – color of the frame position markers, defaults to traj_color if not set

  • traj_frame_marker_size (optional) – size of the frame position markers, defaults to None if not set (markers will be sized automatically by matplotlib)

  • traj_frame_marker_alpha (optional) – alpha of the frame position markers, defaults to 1.0

  • border_line_color (optional) – color of the borders

  • border_line_width (optional) – line width of the borders

  • hole_color (optional) – background color of holes

  • hole_alpha (optional) – alpha of background color for holes

  • title (optional) – title of the plot

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

Returns:

matplotlib.axes.Axes instance where the trajectories are plotted

Return type:

matplotlib.axes.Axes

plot_measurement_setup(*, traj=None, walkable_area=None, measurement_areas=None, measurement_lines=None, axes=None, **kwargs)#

Plot the given measurement setup in 2D.

Parameters:
  • traj (TrajectoryData, optional) – Trajectory object to plot

  • walkable_area (WalkableArea, optional) – WalkableArea object to plot

  • measurement_areas (List[MeasurementArea], optional) – List of measurement areas to plot

  • measurement_lines (List[MeasurementLine], optional) – List of measurement lines to plot

  • axes (matplotlib.axes.Axes, optional) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • ma_line_color (optional) – color of the measurement areas borders

  • ma_line_width (optional) – line width of the measurement areas borders

  • ma_color (optional) – fill color of the measurement areas

  • ma_alpha (optional) – alpha of measurement area fill color

  • ml_color (optional) – color of the measurement lines

  • ml_width (optional) – line width of the measurement lines

  • traj_color (optional) – color of the trajectories

  • traj_width (optional) – width of the trajectories

  • traj_alpha (optional) – alpha of the trajectories

  • traj_start_marker (optional) – marker to indicate the start of the trajectory

  • traj_start_color (optional) – color of the start marker, defaults to traj_color if not set

  • traj_start_marker_size (optional) – size of the start marker

  • traj_start_marker_alpha (optional) – alpha of the start marker

  • traj_end_marker (optional) – marker to indicate the end of the trajectory

  • traj_end_color (optional) – color of the end marker, defaults to traj_color if not set

  • traj_end_marker_size (optional) – size of the end marker

  • traj_end_marker_alpha (optional) – alpha of the end marker

  • traj_frame (optional) – frame number at which to plot a position marker for each pedestrian

  • traj_frame_marker (optional) – marker style for the frame position markers

  • traj_frame_color (optional) – color of the frame position markers, defaults to traj_color if not set

  • traj_frame_marker_size (optional) – size of the frame position markers

  • traj_frame_marker_alpha (optional) – alpha of the frame position markers

  • border_line_color (optional) – color of the lines of the borders

  • border_line_width (optional) – line width of the lines of the borders

  • hole_color (optional) – background color of holes/geometries

  • hole_alpha (optional) – alpha of background color for holes/geometries

  • title (optional) – title of the plot

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

Returns:

matplotlib.axes.Axes instance where the measurement setup is plotted

Return type:

matplotlib.axes.Axes

plot_voronoi_cells(*, voronoi_data, frame, traj_data=None, walkable_area=None, measurement_area=None, axes=None, **kwargs)#

Plot the Voronoi cells, walkable able, and measurement area in 2D.

Parameters:
  • voronoi_data (pd.DataFrame) – voronoi polygon data as returned by compute_voronoi_density()

  • frame (int) – frame index

  • traj_data (TrajectoryData, optional) – Will add pedestrian positions to the plot if provided.

  • walkable_area (WalkableArea, optional) – WalkableArea object to plot

  • measurement_area (MeasurementArea, optional) – measurement area used to compute the Voronoi cells

  • axes (matplotlib.axes.Axes, optional) – Axes to plot on, if None new will be created

  • kwargs (Any) – Additional parameters to change the plot appearance, see below for list of usable keywords

Keyword Arguments:
  • title (optional) – title of the plot

  • x_label (optional) – label on the x-axis

  • y_label (optional) – label on the y-axis

  • ped_color (optional) – color used to display current ped positions

  • ped_size (optional) – size of the marker of the current ped positions

  • voronoi_border_color (optional) – border color of Voronoi cells

  • voronoi_border_width (optional) – border width of the Voronoi cells

  • voronoi_inside_ma_alpha (optional) – alpha of part of Voronoi cell inside the measurement area, data needs to contain column “intersection”!

  • voronoi_outside_ma_alpha (optional) – alpha of part of Voronoi cell outside the measurement area

  • color_by_column (str, optional) – Optionally provide a column name to specify the data to color the cell. Only supports Integer and Float data types. E.g. color_by_column DENSITY_COL

  • vmin (optional) – vmin of colormap, only used when color_mode != “id”

  • vmax (optional) – vmax of colormap, only used when color_mode != “id”

  • cmap (optional) – colormap used for

  • show_colorbar (optional) – colorbar is displayed, only used when color_mode != “id”

  • cb_location (optional) – location of the colorbar, only used when color_mode != “id”

  • cb_label (optional) – label of colorbar

  • ma_line_color (optional) – color of the measurement areas borders

  • ma_line_width (optional) – line width of the measurement areas borders

  • ma_color (optional) – fill color of the measurement areas

  • ma_alpha (optional) – alpha of measurement area fill color

  • ml_color (optional) – color of the measurement lines

  • ml_width (optional) – line width of the measurement lines

  • line_color (optional) – color of the borders

  • line_width (optional) – line width of the borders

  • hole_color (optional) – background color of holes

  • hole_alpha (optional) – alpha of background color for holes

Returns:

matplotlib.axes.Axes instance where the Voronoi cells are plotted

Return type:

matplotlib.axes.Axes