Use ribs.visualize to plot the distribution of objective values in an archive.
archive_histogram: Plots a histogram of objective values for a single archive. Supports a cmap argument for coloring.archive_ecdf: Plots the empirical cumulative distribution function (ECDF) for a single archive. Use complementary=True to plot the ECCDF.aggregate_cdf: Plots the CDF or CCDF aggregated over multiple archives. This is useful for comparing performance across multiple runs. Supports estimator (e.g., 'median') and errorbar (e.g., 'iqr') arguments.
import numpy as np
import matplotlib.pyplot as plt
from ribs.archives import GridArchive
from ribs.visualize import archive_histogram, archive_ecdf
# Setup archive
archive = GridArchive(solution_dim=2, dims=[100, 100], ranges=[(-1, 1), (-1, 1)])
x = np.random.uniform(-1, 1, 10000)
y = np.random.uniform(-1, 1, 10000)
archive.add(solution=np.stack((x, y), axis=1), objective=-(x**2 + y**2), measures=np.stack((x, y), axis=1))
# Plotting
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(16,6))
archive_histogram(archive, ax=ax1, cmap="magma")
ax1.set(title="Histogram", xlabel="Objective", ylabel="Num. Elites")
archive_ecdf(archive, ax=ax2, complementary=True, stat="count", color="#7e57c2")
ax2.set(title="ECCDF", xlabel="Objective", ylabel="Num. Elites")
plt.show()