egttools.plotting.network_plots.plot_parameter_sweep¶
- plot_parameter_sweep(cooperation_matrix, x_values, y_values, xlabel='Parameter X', ylabel='Parameter Y', title='Cooperation level', cmap='RdBu_r', vmin=0.0, vmax=1.0, ax=None, colorbar=True)[source]¶
Plot a 2-D parameter sweep as a heatmap.
- Parameters:
cooperation_matrix (numpy.ndarray, shape (len(y_values), len(x_values))) – Mean cooperation level (or any scalar metric) for each parameter combination. Rows correspond to
y_values, columns tox_values.x_values (sequence of float) – Values swept along the x-axis.
y_values (sequence of float) – Values swept along the y-axis.
xlabel (str)
ylabel (str)
title (str)
cmap (str) – Matplotlib colormap name.
vmin (float) – Colour scale limits.
vmax (float) – Colour scale limits.
ax (matplotlib.axes.Axes, optional)
colorbar (bool)
- Return type:
matplotlib.axes.Axes
Example
>>> import numpy as np >>> betas = np.linspace(0, 5, 20) >>> rewire_probs = np.linspace(0, 1, 20) >>> coop = np.zeros((len(rewire_probs), len(betas))) >>> # ... fill coop via nested loops calling estimate_strategy_distribution ... >>> plot_parameter_sweep(coop, betas, rewire_probs, ... xlabel="beta", ylabel="rewiring probability")