Skip to content

Commit 2c595f3

Browse files
authored
chore: Custom x label for plotting (#233)
1 parent dcdc098 commit 2c595f3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

qdax/utils/plotting.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ def plot_map_elites_results(
222222
repertoire: MapElitesRepertoire,
223223
min_descriptor: jnp.ndarray,
224224
max_descriptor: jnp.ndarray,
225+
x_label: str = "Environment steps",
225226
) -> Tuple[Optional[Figure], Axes]:
226227
"""Plots three usual QD metrics, namely the coverage, the maximum fitness
227228
and the QD-score, along the number of environment steps. This function also
@@ -235,6 +236,7 @@ def plot_map_elites_results(
235236
repertoire: the final repertoire obtained.
236237
min_descriptor: the minimal possible values for the descriptor.
237238
max_descriptor: the maximal possible values for the descriptor.
239+
x_label: label for the x axis, defaults to environment steps
238240
239241
Returns:
240242
A figure and axes with the plots of the metrics and visualisation of the grid.
@@ -259,19 +261,19 @@ def plot_map_elites_results(
259261
# env_steps = jnp.arange(num_iterations) * episode_length * batch_size
260262

261263
axes[0].plot(env_steps, metrics["coverage"])
262-
axes[0].set_xlabel("Environment steps")
264+
axes[0].set_xlabel(x_label)
263265
axes[0].set_ylabel("Coverage in %")
264266
axes[0].set_title("Coverage evolution during training")
265267
axes[0].set_aspect(0.95 / axes[0].get_data_ratio(), adjustable="box")
266268

267269
axes[1].plot(env_steps, metrics["max_fitness"])
268-
axes[1].set_xlabel("Environment steps")
270+
axes[1].set_xlabel(x_label)
269271
axes[1].set_ylabel("Maximum fitness")
270272
axes[1].set_title("Maximum fitness evolution during training")
271273
axes[1].set_aspect(0.95 / axes[1].get_data_ratio(), adjustable="box")
272274

273275
axes[2].plot(env_steps, metrics["qd_score"])
274-
axes[2].set_xlabel("Environment steps")
276+
axes[2].set_xlabel(x_label)
275277
axes[2].set_ylabel("QD Score")
276278
axes[2].set_title("QD Score evolution during training")
277279
axes[2].set_aspect(0.95 / axes[2].get_data_ratio(), adjustable="box")

0 commit comments

Comments
 (0)