Visualization
Each plot answers a single question. They share the resource’s six semantic colours, so a figure in a notebook and a diagram on the website agree about what a colour means.
Import from cooperative_marl_labs.visualization.
Functions
Section titled “Functions”plot_protocol_heatmap
Section titled “plot_protocol_heatmap”from cooperative_marl_labs.visualization import plot_protocol_heatmap
plot_protocol_heatmap( matrix: np.ndarray, target_names: list[str] | None = None, title: str = 'Learned protocol P(m | target)', ax=None,)One row per target, one column per symbol.
A converged protocol has exactly one bright cell per row. A row spread evenly across several columns means the speaker never committed to a convention for that target.
plot_crossplay_matrix
Section titled “plot_crossplay_matrix”from cooperative_marl_labs.visualization import plot_crossplay_matrix
plot_crossplay_matrix( df: pd.DataFrame, title: str = 'Cross-play', ax=None, vmax: float | None = None,)Every ego against every partner, with the familiar pairings outlined.
The diagonal is what a standard evaluation reports. The off-diagonal is the number that says whether anything generalized, so read the two together or the figure says nothing.
plot_partner_estimate
Section titled “plot_partner_estimate”from cooperative_marl_labs.visualization import plot_partner_estimate
plot_partner_estimate( estimates, truth=None, switch_at: int | None = None, title: str = 'What the ego believes about its partner', ax=None,)An estimator’s belief over time, against the truth it is chasing.
Parameters
estimates: Estimated P(FETCH) after each step. truth: The partner’s actual P(FETCH), a scalar or one value per step. switch_at: Step at which the partner was replaced, marked with a vertical rule. A windowed estimator crosses to the new value; one that averages the whole history does not.
render_wireless_network
Section titled “render_wireless_network”from cooperative_marl_labs.visualization import render_wireless_network
render_wireless_network( env, actions=None, title: str = 'Channel allocation', ax=None, show_users: bool = True,)Draw the current allocation.
Parameters
env:
A WirelessResourceAllocationEnv. Its positions, demands and
coupling matrix are what get drawn.
actions:
Channel per access point. Defaults to the environment’s last step.
plot_wireless_comparison
Section titled “plot_wireless_comparison”from cooperative_marl_labs.visualization import plot_wireless_comparison
plot_wireless_comparison( results: dict[str, dict[str, float]], metric: str = 'team_reward', ceiling: float | None = None, title: str | None = None, ax=None,)One bar per system, in the order given.
Parameters
results:
{system name: metrics dict}, as returned by evaluate_agents.
ceiling:
Best achievable value, drawn as a rule. A bar chart without it invites
the reader to treat the tallest bar as good rather than as best so far.
channel_colour
Section titled “channel_colour”from cooperative_marl_labs.visualization import channel_colour
channel_colour(channel: int) -> strThe colour for one channel, wrapping if there are more than five.
The same three colours the lab illustration uses, so a plot and the picture on the website agree about which channel is which.
Constants
Section titled “Constants”| Name | Value |
|---|---|
CHANNEL_COLOURS | ('#5448c8', '#2191fb', '#5da271', '#fea82f', '#fc5130') |