Plots#
2D Visualization Module#
This module provides visualization tools for analyzing and understanding the dynamics of agents and resource distributions in 2D domains for influencer games. It includes utilities for plotting agent positions, influence distributions, and bifurcation dynamics in 2D rectangular domains.
The module is designed to work with the InflGame.adaptive subpackage and supports creating visual representations of agent behaviors and resource distributions in 2D environments.
Usage:#
The functions in this module can be used to visualize agent dynamics and resource distributions in 2D domains. For example, the dist_and_pos_plot_2d_simple function can be used to plot agent positions over time and their influence distributions.
Functions
- InflGame.domains.two_d.two_plots.dist_and_pos_plot_2d_simple(num_agents, bin_points, cmap1, cmap2, pos_matrix, infl_dist, resource_type, x_min=None, y_min=None, domain_bounds=None, resources=0, font={'cbar_size': 12, 'default_size': 12, 'font_family': 'sans-serif', 'legend_size': 12, 'sub_title_size': 12, 'title_size': 14})#
Plots the positions of agents over time and their influence distributions.
- Parameters:
num_agents (int) – Number of agents.
bin_points (np.ndarray) – Points representing resource bins.
rect_X (np.ndarray) – X-coordinates of the rectangular grid.
rect_Y (np.ndarray) – Y-coordinates of the rectangular grid.
cmap1 (Any) – Colormap for agent positions.
cmap2 (Any) – Colormap for influence distributions.
pos_matrix (torch.Tensor) – Tensor containing agent positions over time.
infl_dist (torch.Tensor) – Tensor containing influence distributions.
resource_type (str) – Type of resource distribution.
resources (str, optional) – Resource values, defaults to 0.
- Returns:
The generated plot figure.
- Return type:
matplotlib.figure.Figure
- InflGame.domains.two_d.two_plots.dist_plot_2d(agent_id, infl_dist, rect_Y, rect_X)#
Plots the influence distribution of a single agent.
- Parameters:
agent_id (int) – ID of the agent.
infl_dist (torch.Tensor) – Tensor containing influence distributions.
rect_Y (np.ndarray) – Y-coordinates of the rectangular grid.
rect_X (np.ndarray) – X-coordinates of the rectangular grid.
- Returns:
The generated plot figure.
- Return type:
matplotlib.figure.Figure
- InflGame.domains.two_d.two_plots.equilibrium_bifurcation_plot_2d_simple(num_agents, domain_bounds, reach_num_points, final_pos_matrix, title_ads, font={'cbar_size': 12, 'default_size': 12, 'font_family': 'sans-serif', 'legend_size': 12, 'title_size': 14})#
Plots the bifurcation of agents’ final positions for different parameter values.
- Parameters:
num_agents (int) – Number of agents.
domain_bounds (np.ndarray) – Bounds of the domain.
reach_num_points (int) – Number of points in the reach.
final_pos_matrix (torch.Tensor) – Tensor containing final positions of agents.
title_ads (list) – Additional strings to append to the plot title.
- Returns:
The generated plot figure.
- Return type:
matplotlib.figure.Figure