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.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_agents (int) – Number of agents.
bin_points (numpy.ndarray) – Array of bin points in barycentric coordinates.
r2 (list[float]) – Range of the simplex.
corners (numpy.ndarray) – Coordinates of the simplex corners.
triangle (matplotlib.tri.Triangulation) – Triangulation object for the simplex.
trimesh (matplotlib.tri.Triangulation) – Triangulation mesh for contour plotting.
typelabels (list[str]) – Labels for the simplex corners.
cmap1 (matplotlib.colors.Colormap) – Colormap for agent positions.
cmap2 (matplotlib.colors.Colormap) – Colormap for influence distributions.
pos_matrix (torch.Tensor) – Position matrix of agents in barycentric coordinates.
infl_dist (torch.Tensor) – Influence distribution tensor.
resource_type (str) – Type of resource distribution.
resources (numpy.ndarray) – Resource distribution values.
- Returns:
The generated plot figure.
- Return type:
matplotlib.figure.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_id (int) – ID of the agent.
r2 (list[float]) – Range of the simplex.
corners (numpy.ndarray) – Coordinates of the simplex corners.
triangle (matplotlib.tri.Triangulation) – Triangulation object for the simplex.
trimesh (matplotlib.tri.Triangulation) – Triangulation mesh for contour plotting.
infl_dist (torch.Tensor) – Influence distribution tensor.
cmap (matplotlib.colors.Colormap) – Colormap for the plot.
typelabels (list[str]) – Labels for the simplex corners.
margin (float) – 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_agents (int) – Number of agents.
r2 (list[float]) – Range of the simplex.
corners (numpy.ndarray) – Coordinates of the simplex corners.
triangle (matplotlib.tri.Triangulation) – Triangulation object for the simplex.
final_pos_matrix (torch.Tensor) – Final positions of agents in barycentric coordinates.
reach_num_points (int) – Number of points reached.
title_ads (list[str]) – Additional strings for the plot title.
type_labels (list[str], optional) – Labels for the simplex corners. Defaults to None.
- Returns:
The generated plot figure.
- Return type:
matplotlib.figure.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})#
Plots the positions of agents and bin points on a simplex.
- Parameters:
num_agents (int) – Number of agents.
bin_points (numpy.ndarray) – Array of bin points in barycentric coordinates.
corners (numpy.ndarray) – Coordinates of the simplex corners.
triangle (matplotlib.tri.Triangulation) – Triangulation object for the simplex.
pos_matrix (torch.Tensor) – Position matrix of agents in barycentric coordinates.
- Returns:
The generated plot figure.
- Return type:
matplotlib.figure.Figure
- InflGame.domains.simplex.simplex_plots.simplex_plot_resources(domain_bounds, resources)#
Plots the resource distribution on a simplex.
- Parameters:
domain_bounds (tuple) – Bounds of the simplex domain.
resources (numpy.ndarray) – Resource distribution values.
- Returns:
The generated plot figure.
- Return type:
matplotlib.figure.Figure