Plots#
Simplex Visualization Module#
This module provides visualization tools for analyzing and understanding the dynamics of agents and resource distributions on simplex domains for influencer games. It includes utilities for plotting agent positions, influence distributions, and bifurcation dynamics on simplex domains.
The module is designed to work with the InflGame.adaptive subpackage and supports creating visual representations of agent behaviors and resource distributions in simplex environments.
Dependencies:#
numpy
torch
matplotlib
InflGame.domains.simplex.simplex_utils
Usage:#
The functions in this module can be used to visualize agent dynamics and resource distributions on simplex domains. For example, the pos_plot_simplex function can be used to plot agent positions on a simplex, while the dist_and_pos_plot_simplex function can visualize both agent positions and influence distributions.
Functions
- InflGame.domains.simplex.simplex_plots.agent_density_3d_simplex(pos_matrix, num_agents, domain_bounds, bins=10, distance_threshold=0.05, cmap='viridis', font={'cbar_size': 16, 'default_size': 15, 'font_family': 'sans-serif', 'legend_size': 12, 'title_size': 18}, figsize=(20, 16), xlabel='$x$', ylabel='$y$', zlabel='Number of Agents', axis_return=False, edgecolor='black', linewidth=0.2, alpha=0.9, title_ads=[], save=False, name_ads=[], save_types=['.png', '.svg'], paper_figure={'figure_id': 'agent_density_3d', 'paper': False, 'section': 'A'}, id=0, cap_z_axis=True, integer_ticks=True)#
Create a 3D histogram showing agent density at final positions for simplex domain.
- Parameters:
- pos_matrixnp.ndarray or torch.Tensor
Position matrix of shape (time_steps, num_agents, 3) in barycentric coordinates.
- num_agentsint
Number of agents.
- domain_boundstuple
Simplex domain bounds tuple containing (r2, corners, triangle, trimesh).
- binsint
Number of bins in each dimension.
- distance_thresholdfloat
Distance threshold for clustering nearby agents.
- cmapstr
Colormap name.
- fontdict
Font configuration dictionary.
- figsizetuple
Figure size as (width, height).
- xlabelstr
Label for x-axis.
- ylabelstr
Label for y-axis.
- zlabelstr
Label for z-axis.
- axis_returnbool
If True, return axes object; if False, return figure object.
- edgecolorstr
Color of outlines around bars.
- linewidthfloat
Width of bar edge lines.
- alphafloat
Bar transparency.
- title_adslist
Additional titles for the plot.
- savebool
Whether to save the plot.
- name_adslist
Additional names for saved files.
- save_typeslist
File types to save the plot.
- paper_figuredict
Dictionary for paper figure naming.
- idint
Identifier for file naming.
- cap_z_axisbool
If True, cap the z-axis maximum at num_agents.
- integer_ticksbool
If True, only show integer ticks on the z-axis.
- Returns:
- matplotlib.figure.Figure
The generated plot figure.
- InflGame.domains.simplex.simplex_plots.dist_and_pos_plot_simplex(num_agents, bin_points, r2, corners, triangle, trimesh, typelabels, cmap1, cmap2, pos_matrix, infl_dist, resource_type, resources=0, font={'cbar_size': 12, 'default_size': 12, 'font_family': 'sans-serif', 'legend_size': 12, 'subtitle_size': 12, 'title_size': 14})#
Plots both the positions of agents and their influence distributions on a simplex.
- Parameters:
- num_agentsint
Number of agents.
- bin_pointsnumpy.ndarray
Array of bin points in barycentric coordinates.
- r2list[float]
Range of the simplex.
- cornersnumpy.ndarray
Coordinates of the simplex corners.
- trianglematplotlib.tri.Triangulation
Triangulation object for the simplex.
- trimeshmatplotlib.tri.Triangulation
Triangulation mesh for contour plotting.
- typelabelslist[str]
Labels for the simplex corners.
- cmap1matplotlib.colors.Colormap
Colormap for agent positions.
- cmap2matplotlib.colors.Colormap
Colormap for influence distributions.
- pos_matrixtorch.Tensor
Position matrix of agents in barycentric coordinates.
- infl_disttorch.Tensor
Influence distribution tensor.
- resource_typestr
Type of resource distribution.
- resourcesnumpy.ndarray
Resource distribution values.
- Returns:
- matplotlib.figure.Figure
The generated plot figure.
- InflGame.domains.simplex.simplex_plots.dist_plot_simplex(agent_id, r2, corners, triangle, trimesh, infl_dist, cmap, typelabels, margin=0.01, font={'default_size': 12, 'font_family': 'sans-serif', 'legend_size': 12, 'title_size': 14}, **kwargs)#
Plots the influence distribution of a single agent on a simplex.
- Parameters:
- agent_idint
ID of the agent.
- r2list[float]
Range of the simplex.
- cornersnumpy.ndarray
Coordinates of the simplex corners.
- trianglematplotlib.tri.Triangulation
Triangulation object for the simplex.
- trimeshmatplotlib.tri.Triangulation
Triangulation mesh for contour plotting.
- infl_disttorch.Tensor
Influence distribution tensor.
- cmapmatplotlib.colors.Colormap
Colormap for the plot.
- typelabelslist[str]
Labels for the simplex corners.
- marginfloat
Margin for the plot axes.
- kwargs
Additional arguments for contour plotting.
- Returns:
- None
- InflGame.domains.simplex.simplex_plots.equalibirium_bifurication_plot_simplex(num_agents, r2, corners, triangle, final_pos_matrix, reach_num_points, title_ads, type_labels=None, font={'default_size': 12, 'font_family': 'sans-serif', 'legend_size': 12, 'sub_title_size': 12, 'title_size': 14})#
Plots the equilibrium bifurcation of agents on a simplex.
- Parameters:
- num_agentsint
Number of agents.
- r2list[float]
Range of the simplex.
- cornersnumpy.ndarray
Coordinates of the simplex corners.
- trianglematplotlib.tri.Triangulation
Triangulation object for the simplex.
- final_pos_matrixtorch.Tensor
Final positions of agents in barycentric coordinates.
- reach_num_pointsint
Number of points reached.
- title_adslist[str]
Additional strings for the plot title.
- type_labelslist[str], optional
Labels for the simplex corners. Defaults to None.
- Returns:
- matplotlib.figure.Figure
The generated plot figure.
- InflGame.domains.simplex.simplex_plots.pos_plot_simplex(num_agents, bin_points, corners, triangle, pos_matrix, font={'default_size': 12, 'font_family': 'sans-serif', 'legend_size': 12, 'sub_title_size': 12, 'title_size': 14}, fig_size=(18, 18))#
Plots the positions of agents and bin points on a simplex.
- Parameters:
- num_agentsint
Number of agents.
- bin_pointsnumpy.ndarray
Array of bin points in barycentric coordinates.
- cornersnumpy.ndarray
Coordinates of the simplex corners.
- trianglematplotlib.tri.Triangulation
Triangulation object for the simplex.
- pos_matrixtorch.Tensor
Position matrix of agents in barycentric coordinates.
- Returns:
- matplotlib.figure.Figure
The generated plot figure.
- InflGame.domains.simplex.simplex_plots.simplex_plot_resources(domain_bounds, resources)#
Plots the resource distribution on a simplex.
- Parameters:
- domain_boundstuple
Bounds of the simplex domain.
- resourcesnumpy.ndarray
Resource distribution values.
- Returns:
- matplotlib.figure.Figure
The generated plot figure.