def plot_bars()

in code/experiment_synthetic/plot.py [0:0]


def plot_bars(results, category, which, sep=1.1):
    models = list(results[list(results.keys())[0]].keys())

    if "SEM" in models:
        models.remove("SEM")
    models.sort()

    setups = list(results.keys())
    setups.sort()

    if which == "causal":
        hatch = None
        offset = 0
        idx = 0
    else:
        hatch = "//"
        offset = 4
        idx = 1

    counter = 1
    for s, setup in enumerate(setups):
        title = parse_title(setup)

        if category not in title:
            continue

        boxes = []
        boxes_means = []
        boxes_colors = []
        boxes_vars = []
        ax = plt.subplot(2, 4, counter + offset)
        counter += 1

        for m, model in enumerate(models):
            boxes.append(np.array(results[setup][model])[:, idx])
            boxes_means.append(
                np.mean(np.array(results[setup][model])[:, idx]))
            boxes_vars.append(np.std(np.array(results[setup][model])[:, idx]))
            boxes_colors.append("C" + str(m))

        plt.bar([0, 1, 2],
                boxes_means,
                yerr=np.array(boxes_vars),
                color=boxes_colors,
                hatch=hatch,
                alpha=0.7,
                log=True)

        if which == "causal":
            plt.xticks([1], [title])
        else:
            ax.xaxis.set_ticks_position('top')
            plt.xticks([1], [""])

        if (counter + offset) == 2 or (counter + offset) == 6:
            if which == "causal":
                plt.ylabel("causal error")
            else:
                plt.ylabel("non-causal error")

        if title == "PES" and which != "causal":
            legends = []
            for m, model in enumerate(models):
                legends.append(
                    Patch(facecolor="C" + str(m), alpha=0.7, label=model))
            plt.legend(handles=legends, loc="lower center")

        if title == "POU" and which != "causal":
            plt.minorticks_off()
            ax.set_yticks([0.1, 0.01])