def plot_experiment()

in phasic_policy_gradient/graph_util.py [0:0]


def plot_experiment(csv_file_groups, titles=None, normalization_ranges=None, key_name='eprewmean', labels=None, bbox_to_anchor=(.5, 0, .5, 1), **kwargs):
    num_envs = len(ENV_NAMES)
    will_normalize_and_reduce = normalization_ranges is not None

    if will_normalize_and_reduce:
        num_visible_plots = 1
        f, axarr = plt.subplots()
    else:
        num_visible_plots = num_envs
        dimx = dimy = ceil(np.sqrt(num_visible_plots))
        f, axarr = plt.subplots(dimx, dimy, sharex=True)

    if len(csv_file_groups) > 1:
        # we need multiple colors
        num_curves = len(csv_file_groups)
        colors = [(255 - x, x, x) for x in [(255 // (num_curves - 1)) * i for i in range(num_curves)]]
    else:
        colors = [(57, 106, 177)]

    for curve_idx, csv_file_group in enumerate(csv_file_groups):
        all_values = []
        game_weights = [1] * num_envs

        for env_idx in range(num_envs):
            env_name = ENV_NAMES[env_idx]
            label = labels[curve_idx] if labels is not None else None
            color = colors[curve_idx]
            if num_visible_plots > 1 and env_idx != 0:
                label = None # only label the first graph to avoid legend duplicates
            print(f'loading results from {env_name}...')

            if num_visible_plots == 1:
                ax = axarr
            else:
                dimy = len(axarr[0])
                ax = axarr[env_idx // dimy][env_idx % dimy]

            csv_files = [f"results/{dir_name}/progress-{env_name}.csv" for dir_name in csv_file_group]
            curr_ax = None if will_normalize_and_reduce else ax

            raw_data = np.array([read_csv(file, key_name) for file in csv_files])
            values = plot_values(curr_ax, raw_data, title=env_name, color=color, label=label, **kwargs)

            if will_normalize_and_reduce:
                game_range = normalization_ranges[env_name]
                game_min = game_range[0]
                game_max = game_range[1]
                game_delta = game_max - game_min
                sub_values = game_weights[env_idx] * (np.array(values) - game_min) / (game_delta)
                all_values.append(sub_values)

        if will_normalize_and_reduce:
            normalized_data = np.sum(all_values, axis=0)
            normalized_data = normalized_data / np.sum(game_weights)
            title = 'Mean Normalized Score'
            plot_values(ax, normalized_data, title=None, color=color, label=label, **kwargs)

    if num_visible_plots == 1:
        ax.legend(loc='lower right', bbox_to_anchor=bbox_to_anchor)
    else:
        matplotlib.rcParams.update({'legend.fontsize': 11})
        f.legend(loc='lower left')

    return f, axarr