def figure(runs, methods, args):
    tasks = sorted(set((r.task for r in runs if (r.xs is not None))))
    rows = int(np.ceil(((len(tasks) + len(args.add)) / args.cols)))
    figsize = ((args.size[0] * args.cols), (args.size[1] * rows))
    (fig, axes) = plt.subplots(rows, args.cols, figsize=figsize)
    for (task, ax) in zip(tasks, axes.flatten()):
        relevant = [r for r in runs if (r.task == task)]
        plot(task, ax, relevant, methods, args)
    for (name, ax) in zip(args.add, axes.flatten()[len(tasks):]):
        ax.set_facecolor((0.9, 0.9, 0.9))
        if (name == 'median'):
            plot_combined('combined_median', ax, runs, methods, args, lo='random', hi='human$', agg=(lambda x: np.nanmedian(x, (- 1))))
        elif (name == 'mean'):
            plot_combined('combined_mean', ax, runs, methods, args, lo='random', hi='human$', agg=(lambda x: np.nanmean(x, (- 1))))
        elif (name == 'gamer_median'):
            plot_combined('combined_gamer_median', ax, runs, methods, args, lo='random', hi='human$', agg=(lambda x: np.nanmedian(x, (- 1))))
        elif (name == 'gamer_mean'):
            plot_combined('combined_gamer_mean', ax, runs, methods, args, lo='random', hi='human$', agg=(lambda x: np.nanmean(x, (- 1))))
        elif (name == 'record_mean'):
            plot_combined('combined_record_mean', ax, runs, methods, args, lo='random', hi='record', agg=(lambda x: np.nanmean(x, (- 1))))
        elif (name == 'clipped_record_mean'):
            plot_combined('combined_clipped_record_mean', ax, runs, methods, args, lo='random', hi='record', clip=True, agg=(lambda x: np.nanmean(x, (- 1))))
        elif (name == 'num_seeds'):
            plot_combined('combined_num_seeds', ax, runs, methods, args, agg=(lambda x: np.isfinite(x).sum((- 1))))
        elif (name == 'human_above'):
            plot_combined('combined_above_human$', ax, runs, methods, args, agg=(lambda y: (y >= 1.0).astype(float).sum((- 1))))
        elif (name == 'human_below'):
            plot_combined('combined_below_human$', ax, runs, methods, args, agg=(lambda y: (y <= 1.0).astype(float).sum((- 1))))
        else:
            raise NotImplementedError(name)
    if args.xlim:
        for ax in axes[:(- 1)].flatten():
            ax.xaxis.get_offset_text().set_visible(False)
    if args.xlabel:
        for ax in axes[(- 1)]:
            ax.set_xlabel(args.xlabel)
    if args.ylabel:
        for ax in axes[:, 0]:
            ax.set_ylabel(args.ylabel)
    for ax in axes.flatten()[(len(tasks) + len(args.add)):]:
        ax.axis('off')
    legend(fig, args.labels, **LEGEND)
    return fig
def figure(runs, methods, args):
    tasks = sorted(set((r.task for r in runs if (r.xs is not None))))
    rows = int(np.ceil(((len(tasks) + len(args.add)) / args.cols)))
    figsize = ((args.size[0] * args.cols), (args.size[1] * rows))
    (fig, axes) = plt.subplots(rows, args.cols, figsize=figsize)
    for (task, ax) in zip(tasks, axes.flatten()):
        relevant = [r for r in runs if (r.task == task)]
        plot(task, ax, relevant, methods, args)
    for (name, ax) in zip(args.add, axes.flatten()[len(tasks):]):
        ax.set_facecolor((0.9, 0.9, 0.9))
        if (name == 'median'):
            plot_combined('combined_median', ax, runs, methods, args, lo='random', hi='human$', agg=(lambda x: np.nanmedian(x, (- 1))))
        elif (name == 'mean'):
            plot_combined('combined_mean', ax, runs, methods, args, lo='random', hi='human$', agg=(lambda x: np.nanmean(x, (- 1))))
        elif (name == 'gamer_median'):
            plot_combined('combined_gamer_median', ax, runs, methods, args, lo='random', hi='human$', agg=(lambda x: np.nanmedian(x, (- 1))))
        elif (name == 'gamer_mean'):
            plot_combined('combined_gamer_mean', ax, runs, methods, args, lo='random', hi='human$', agg=(lambda x: np.nanmean(x, (- 1))))
        elif (name == 'record_mean'):
            plot_combined('combined_record_mean', ax, runs, methods, args, lo='random', hi='record', agg=(lambda x: np.nanmean(x, (- 1))))
        elif (name == 'clipped_record_mean'):
            plot_combined('combined_clipped_record_mean', ax, runs, methods, args, lo='random', hi='record', clip=True, agg=(lambda x: np.nanmean(x, (- 1))))
        elif (name == 'num_seeds'):
            plot_combined('combined_num_seeds', ax, runs, methods, args, agg=(lambda x: np.isfinite(x).sum((- 1))))
        elif (name == 'human_above'):
            plot_combined('combined_above_human$', ax, runs, methods, args, agg=(lambda y: (y >= 1.0).astype(float).sum((- 1))))
        elif (name == 'human_below'):
            plot_combined('combined_below_human$', ax, runs, methods, args, agg=(lambda y: (y <= 1.0).astype(float).sum((- 1))))
        else:
            raise NotImplementedError(name)
    if args.xlim:
        for ax in axes[:(- 1)].flatten():
            ax.xaxis.get_offset_text().set_visible(False)
    if args.xlabel:
        for ax in axes[(- 1)]:
            ax.set_xlabel(args.xlabel)
    if args.ylabel:
        for ax in axes[:, 0]:
            ax.set_ylabel(args.ylabel)
    for ax in axes.flatten()[(len(tasks) + len(args.add)):]:
        ax.axis('off')
    legend(fig, args.labels, **LEGEND)
    return fig