plot
plot
Contains functions to plot the geometric shapes of the pedestrian, the crowd and the anthropometric data.
- streamlit_app.plot.plot.display_shape2D(agents)[source]
Generate a Plotly figure visualizing the 2D shapes of the given agents.
- Parameters:
- Returns:
Plotly figure displaying the agents' 2D shapes.
- Return type:
go.Figure
Notes
If an agent's shape is a Polygon, it is directly plotted with its exterior boundary.
If an agent's shape is a MultiPolygon, each individual polygon in the collection is plotted separately.
The centroid of each shape (or collection of shapes) is computed and annotated with the corresponding agent's ID.
- streamlit_app.plot.plot.display_body3D_orthogonal_projection(agent, extra_info=None)[source]
Generate a matplotlib figure showing the orthogonal projection of a pedestrian's 3D body.
- Parameters:
agent (Agent) -- An Agent object with 3D shapes accessible via agent.shapes3D.shapes, where keys are heights as float and values are MultiPolygon.
extra_info (tuple[DeltaGenerator, DeltaGenerator], optional) --
- A tuple containing:
DeltaGenerator: Streamlit object for updating the progress bar.
DeltaGenerator: Streamlit object for displaying status messages.
- Returns:
Matplotlib figure showing the orthogonal projection of the pedestrian's 3D body.
- Return type:
matplotlib.figure.Figure
- Raises:
ValueError -- If agent.shapes3D or agent.shapes3D.shapes is None. If any shape in agent.shapes3D.shapes is not a MultiPolygon.
- streamlit_app.plot.plot.display_body3D_polygons(agent, extra_info=None)[source]
Generate a Plotly figure object of a 3D representation of an agent body from the polygons that constitute it.
- Parameters:
agent (Agent) -- The agent object containing 3D shapes (agent.shapes3D) and associated measurements.
extra_info (tuple[DeltaGenerator, DeltaGenerator], optional) --
- A tuple containing:
DeltaGenerator: Streamlit object for updating the progress bar.
DeltaGenerator: Streamlit object for displaying status messages.
- Returns:
A Plotly figure object representing the 3D body made of polygons.
- Return type:
go.Figure
- Raises:
ValueError -- If agent.shapes3D or agent.shapes3D.shapes is None, or if any shape in agent.shapes3D.shapes is not a MultiPolygon.
- streamlit_app.plot.plot.display_body3D_mesh(agent, precision=40, extra_info=None)[source]
Generate a Plotly figure object of a continuous 3D mesh connecting contours at different heights.
This function generates a smooth 3D mesh visualization of an agent by connecting shape contours at various heights using Plotly's Mesh3d. It fills missing triangles and smooths the mesh surface.
- Parameters:
agent (Agent) -- An instance of the Agent class containing 3D shape data.
precision (int, optional) -- The number of layers to be displayed in the mesh.
extra_info (tuple[DeltaGenerator, DeltaGenerator], optional) --
- A tuple containing:
DeltaGenerator: Streamlit object for updating the progress bar.
DeltaGenerator: Streamlit object for displaying status messages.
- Returns:
A Plotly Figure object displaying the generated 3D mesh.
- Return type:
go.Figure
- Raises:
ValueError -- If agent.shapes3D or agent.shapes3D.shapes is None.
- streamlit_app.plot.plot.display_crowd2D(crowd)[source]
Generate a matplotlib figure object of a crowd of agents in 2D.
- Parameters:
crowd (Crowd) -- The crowd object containing agents with 2D geometric shapes.
- Returns:
A tuple containing a matplotlib figure object and axes displaying the 2D plot of the crowd.
- Return type:
tuple[matplotlib.figure.Figure, matplotlib.axes.Axes]
- Raises:
AttributeError -- If any agent in the crowd lacks the required 2D shape attributes.
TypeError -- If an agent's geometric shape is neither a Polygon nor a MultiPolygon.
- streamlit_app.plot.plot.display_crowd3D_slices_by_slices(crowd)[source]
Generate an animated Plotly figure of a 3D crowd made of layers of 2D polygons at different altitude.
For a given set of altitutdes, this function plots all polygons at that altitude. If there is not a polygon for a given agent at that specific altitude, then the polygon with the nearest altitude is shown. No interpolation is performed. The result is an animated Plotly figure, where each animation frame corresponds to a different altitude.
- Parameters:
crowd (Crowd) -- The crowd object containing agents.
- Returns:
An animated Plotly figure with a slider to select the altitude. Each frame displays all polygons of all agents at a given altitude. Polygon color encodes agent area. Agent indices are labeled at their centroid.
- Return type:
go.Figure
- streamlit_app.plot.plot.display_crowd3D_whole_3Dscene(crowd)[source]
Generate a 3D Plotly figure of a 3D crowd.
- Parameters:
crowd (Crowd) -- The crowd object containing agents.
- Returns:
A Plotly figure object representing the 3D crowd.
- Return type:
- streamlit_app.plot.plot.display_distribution(df, column)[source]
Generate a Plotly figure of the distribution of a specified DataFrame column as overlaid histograms for each sex.
- Parameters:
df (pd.DataFrame) -- DataFrame containing the data. Must include a 'sex' column.
column (str) -- Name of the column to plot.
- Returns:
Plotly Figure object with overlaid histograms for males and females.
- Return type:
go.Figure
- Raises:
ValueError -- If the specified column or the 'sex' column is not found in the DataFrame.
- streamlit_app.plot.plot.darken(color, factor=0.8)[source]
Return a darker shade of color without changing its hue.
- Parameters:
color (ColorType) -- Any Matplotlib-acceptable color specification.
factor (float, optional) -- Multiplier for RGB channels; < 1 darkens, > 1 lightens.
- Returns:
Darkened color as (r, g, b, a) with components in [0.0, 1.0].
- Return type:
RGBA