jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
rcParams.update({"font.size": 22})
# %%
df = pd.read_csv("experiments/computationalPerformance.csv")
# %%
rows = {
    "Airfoil": 1503,
    "Concrete": 1030,
    "FishToxicity": 908,
    "ForestFire": 517,
    "NewTaipeiHousing": 414,
    "PowerPlant": 9568,
    "Protein": 45730,
    "Servo": 167,
}
# %%
df["rows"] = df.Data.map(rows)
# %%
for model in df.Model.unique():
    ## Params
    if model == "LinearRegression":
        legend = True
    else:
        legend = False

    aux = df[df.Model == model]  # .groupby('Data').mean()
    aux = aux.sort_values("rows")
    aux = aux.drop(columns=["Uncertainty", "rows"])
    aux = aux.melt(id_vars=["Data", "Model"], value_vars=["Nasa", "Doubt", "Mapie"])
    g = sns.factorplot(
        data=aux,
        kind="bar",
        x="Data",
        y="value",
        hue="variable",
        ci="sd",
        palette="dark",
        alpha=0.6,
        size=6,
        legend=False,
    )
    g.despine(left=True)
    g.set_xticklabels(rotation=30)
    g.set_axis_labels("", "Wall Time (s)")
    g.fig.suptitle(model)
    if legend:
        g.add_legend(bbox_to_anchor=(0.3, 0.7))
    g.savefig("experiments/results/computationalPerformance" + model + ".png")
//  [python]
rcParams.update({"font.size": 22})
# %%
df = pd.read_csv("experiments/computationalPerformance.csv")
# %%
rows = {
    "Airfoil": 1503,
    "Concrete": 1030,
    "FishToxicity": 908,
    "ForestFire": 517,
    "NewTaipeiHousing": 414,
    "PowerPlant": 9568,
    "Protein": 45730,
    "Servo": 167,
}
# %%
df["rows"] = df.Data.map(rows)
# %%
for model in df.Model.unique():
    ## Params
    if model == "LinearRegression":
        legend = True
    else:
        legend = False

    aux = df[df.Model == model]  # .groupby('Data').mean()
    aux = aux.sort_values("rows")
    aux = aux.drop(columns=["Uncertainty", "rows"])
    aux = aux.melt(id_vars=["Data", "Model"], value_vars=["Nasa", "Doubt", "Mapie"])
    g = sns.catplot(
        data=aux,
        kind="bar",
        x="Data",
        y="value",
        hue="variable",
        ci="sd",
        palette="dark",
        alpha=0.6,
        height=6,
        legend=False,
    )
    g.despine(left=True)
    g.set_xticklabels(rotation=30)
    g.set_axis_labels("", "Wall Time (s)")
    g.fig.suptitle(model)
    if legend:
        g.add_legend(bbox_to_anchor=(0.3, 0.7))
    g.savefig("experiments/results/computationalPerformance" + model + ".png")
//  [python]
def plot_umi_match_fraction(umi, matches, suffix=""):
    print(ct() + "Plotting fraction of correct barcodes.")

    d = pd.DataFrame(
        [[sum(umi.loc[x]) for x in matches.values()], [umi.sum() for x in matches.values()],],
        index=["correct", "total"],
        columns=matches.keys(),
    )
    d.loc["fraction of exact match", :] = d.loc["correct"] / d.loc["total"]

    grid = sns.factorplot(
        data=d.reset_index().melt(id_vars="index"),
        x="variable",
        y="value",
        col="index",
        sharey=False,
        kind="bar",
        size=3,
        aspect=1,
    )
    grid.fig.savefig(
        args.output_prefix + f"umi_matching.barplot.{suffix}.svg".replace("..", "."),
        dpi=300,
        bbox_inches="tight",
    )
//  [python]
def plot_umi_match_fraction(umi, matches, suffix=""):
    print(ct() + "Plotting fraction of correct barcodes.")

    d = pd.DataFrame(
        [[sum(umi.loc[x]) for x in matches.values()], [umi.sum() for x in matches.values()],],
        index=["correct", "total"],
        columns=matches.keys(),
    )
    d.loc["fraction of exact match", :] = d.loc["correct"] / d.loc["total"]

    grid = sns.catplot(
        data=d.reset_index().melt(id_vars="index"),
        x="variable",
        y="value",
        col="index",
        sharey=False,
        kind="bar",
        height=3,
        aspect=1,
    )
    grid.fig.savefig(
        args.output_prefix + f"umi_matching.barplot.{suffix}.svg".replace("..", "."),
        dpi=300,
        bbox_inches="tight",
    )
//  [python]
def plot_results(results):
    results = results.reset_index()
    results['name'] = results.platform + '/' + results.cpu

    g = seaborn.factorplot(data=results,
        kind='bar',
        y='flash',
        x='dtype',
        row='name',
        size=4,
        aspect=2,
    )
    fig = g.fig
    fig.suptitle("Model size vs feature datatype")

    return fig
//  [python]
def plot_results(results):
    results = results.reset_index()
    results['name'] = results.platform + '/' + results.cpu

    g = seaborn.catplot(data=results,
        kind='bar',
        y='flash',
        x='dtype',
        row='name',
        height=4,
        aspect=2,
    )
    fig = g.figure
    fig.suptitle("Model size vs feature datatype")

    return fig
//  [python]
def plot_overall_stat(stats, model, stat_name, run_name):
    print(f"Plotting {stat_name} histplot")
    plt.figure()
    plot = sns.histplot(stats["snr"], stat='probability')
    plot.set_title(f"{model}".capitalize() + f" {stat_name}")
    plot.set(xlabel=stat_name)
    plt.savefig(f"{run_name}/{model}_{stat_name}.pdf")
    plt.close()

    df = pd.DataFrame({"Neuron Dimension (D)": stats["dims"], stat_name: stats["snr"], 
        "Layer": stats["layers"], "Num Neurons": stats["num_neurons"]})

    print(f"Plotting {stat_name} scatterplots")
    plt.figure()
    plot = sns.violinplot(x="Neuron Dimension (D)", y=stat_name, data=df)
    plt.title(f"{model}".capitalize() + f" {stat_name} by Dimension")
    plt.xticks(rotation=45)
    plt.savefig(f"{run_name}/{stat_name}_by_dim.pdf", bbox_inches="tight")
    plt.close()

    plt.figure()
    plot = sns.violinplot(x="Layer", y=stat_name, data=df)
    plt.title(f"{model}".capitalize() + f" {stat_name} by Layer")
    plt.xticks(rotation=45)
    plt.savefig(f"{run_name}/{stat_name}_by_layer.pdf", bbox_inches="tight")
    plt.close()

    plt.figure()
    plot = sns.violinplot(x="Num Neurons", y=stat_name, data=df)
    plt.title(f"{model}".capitalize() + f" {stat_name} by Num Neurons")
    plt.xticks(rotation=45)
    plt.savefig(f"{run_name}/{stat_name}_by_num_neurons.pdf", bbox_inches="tight")
    plt.close()
//  [python]
def plot_overall_stat(stats, model, stat_name, run_name):
    print(f"Plotting {stat_name} histplot")
    plt.figure()
    plot = sns.histplot(stats["snr"], stat='probability')
    plot.set_title(f"{model}".capitalize() + f" {stat_name}")
    plot.set(xlabel=stat_name)
    plt.savefig(f"{run_name}/{model}_{stat_name}.pdf")
    plt.close()

    df = pd.DataFrame({"Neuron Dimension (D)": stats["dims"], stat_name: stats["snr"], 
        "Layer": stats["layers"], "Num Neurons": stats["num_neurons"]})

    print(f"Plotting {stat_name} scatterplots")
    plt.figure()
    plot = sns.catplot(x="Neuron Dimension (D)", y=stat_name, kind="violin",
            data=df)
    plot.fig.suptitle(f"{model}".capitalize() + f" {stat_name} by Dimension")
    plot.set_xticklabels(rotation=45)
    plt.savefig(f"{run_name}/{stat_name}_by_dim.pdf", bbox_inches="tight")
    plt.close()

    plt.figure()
    plot = sns.catplot(x="Layer", y=stat_name, kind="violin",
            data=df)
    plot.fig.suptitle(f"{model}".capitalize() + f" {stat_name} by Layer")
    plot.set_xticklabels(rotation=45)
    plt.savefig(f"{run_name}/{stat_name}_by_layer.pdf", bbox_inches="tight")
    plt.close()

    plt.figure()
    plot = sns.catplot(x="Num Neurons", y=stat_name, kind="violin",
            data=df)
    plot.fig.suptitle(f"{model}".capitalize() + f" {stat_name} by Num Neurons")
    plot.set_xticklabels(rotation=45)
    plt.savefig(f"{run_name}/{stat_name}_by_num_neurons.pdf", bbox_inches="tight")
    plt.close()
//  [python]
def plot_num_cols(df, col, target='depression'):
    '''
    Generates 'boxen' type catplot on a column in a dataframe grouped by target
    
    Args:
        df (dataframe): Dataframe that contains the column and target to be 
        plotted
        col (str): Column name of the data to be plotted against the target
        target (str): Target column of the dataframe
        
    Returns:
        Catplot 'boxen' figure split by the target 
    
    Example:
        plotting_num_cols(data, 'feature_name')
    '''
    # Generating the figure
    g = sns.catplot(x=target, y=col, data=df, kind='boxen', 
                    height=7, aspect=2)

    # Setting the title
    plt.suptitle(f'{col.title()} and {target.title()}', fontsize=30, y=1.05)
//  [python]
def plot_metrics_with_LLM_all(alg_name, score):
    """
    Compare results with and without LLM for all experiments, 
    and plot the SHD in a bar chart.
    """
    input_path = "out/result-all.csv"
    df = pd.read_csv(input_path)
    df = df[df["alg"] == alg_name]
    df = df[df["score"] == score]
    df = df[df["LLM"].isin(["with", "without"])]
    df["exp name"] = df.apply(
        lambda row: f"{row['d']}-{row['s']}", axis=1)

    # Add the results of the p-test here
    for exp_name in df["exp name"].unique():
        df_exp = df[df["exp name"] == exp_name]
        with_LLM = df_exp[df_exp["LLM"] == "with"]["shd"].values
        without_LLM = df_exp[df_exp["LLM"] == "without"]["shd"].values
        t_stat, p_val = ttest_ind(with_LLM, without_LLM)
        df.loc[df["exp name"] == exp_name, "p_val"] = p_val

    plt.figure()
    catplot = sns.factorplot(data=df, x='exp name', y='shd', hue='LLM',
                          kind='bar', palette=sns.color_palette(),
                          legend_out=False, size=8, aspect=2.5)

    # Looping over the bars to add the values on top
    for i, bar in enumerate(catplot.ax.patches):
        catplot.ax.text(bar.get_x() + bar.get_width() / 2., bar.get_height(),
                        f'{bar.get_height():.2f}',
                        ha='center', va='bottom')

    plt.xticks()
    catplot.set_axis_labels("Dataset", "SHD")
    # Add some space at the top for the p-values
    catplot.set(ylim=(0, df['shd'].max() + 0.1))
    catplot.fig.suptitle(f"{alg_name} {score} SHD")

    plt.legend()

    metrics_img_path = f"img/shd-{alg_name}-{score}.png"
    catplot.savefig(metrics_img_path)
    print(f"📊📊 LLM catplot saved to {metrics_img_path}")
    plt.close()
//  [python]
def plot_metrics_with_LLM_all(alg_name, score):
    """
    Compare results with and without LLM for all experiments, 
    and plot the SHD in a bar chart.
    """
    input_path = "out/result-all.csv"
    df = pd.read_csv(input_path)
    df = df[df["alg"] == alg_name]
    df = df[df["score"] == score]
    df = df[df["LLM"].isin(["with", "without"])]
    df["exp name"] = df.apply(
        lambda row: f"{row['d']}-{row['s']}", axis=1)

    # Add the results of the p-test here
    for exp_name in df["exp name"].unique():
        df_exp = df[df["exp name"] == exp_name]
        with_LLM = df_exp[df_exp["LLM"] == "with"]["shd"].values
        without_LLM = df_exp[df_exp["LLM"] == "without"]["shd"].values
        t_stat, p_val = ttest_ind(with_LLM, without_LLM)
        df.loc[df["exp name"] == exp_name, "p_val"] = p_val

    plt.figure()
    catplot = sns.catplot(data=df, x='exp name', y='shd', hue='LLM',
                          kind='bar', palette=sns.color_palette(),
                          legend_out=False, height=8, aspect=2.5)

    # Looping over the bars to add the values on top
    for i, bar in enumerate(catplot.ax.patches):
        catplot.ax.text(bar.get_x() + bar.get_width() / 2., bar.get_height(),
                        f'{bar.get_height():.2f}',
                        ha='center', va='bottom')

    plt.xticks()
    catplot.set_axis_labels("Dataset", "SHD")
    # Add some space at the top for the p-values
    catplot.set(ylim=(0, df['shd'].max() + 0.1))
    catplot.fig.suptitle(f"{alg_name} {score} SHD")

    plt.legend()

    metrics_img_path = f"img/shd-{alg_name}-{score}.png"
    catplot.savefig(metrics_img_path)
    print(f"📊📊 LLM catplot saved to {metrics_img_path}")
    plt.close()
//  [python]
def throughput_compare(self):
        sns.barplot(data = self.results_pd, x="Experiment", y="Throughput", hue="Experiment")
        plt.savefig("")
//  [python]
def throughput_compare(self):
        sns.catplot(data = self.results_pd, x="Experiment", y="Throughput", hue="Experiment")
        plt.savefig("")
//  [python]
def avg_latency_compare(self):
        sns.barplot(data = self.results_pd, x="Experiment", y="Latency Avg", hue="Experiment")
        plt.savefig("")
//  [python]
def avg_latency_compare(self):
        sns.catplot(data = self.results_pd, x="Experiment", y="Latency Avg", hue="Experiment")
        plt.savefig("")
//  [python]
def plotting_percentages(df, col, target='depression'):
    '''
    Generates catplot on a column in a dataframe that shows percentages at the
    top of each bar.
    
    Args:
        df (dataframe): Dataframe that contains the column and target to be 
        plotted
        col (str): Column name of the data to be plotted against the target
        target (str): Target column of the dataframe
        
    Returns:
        Catplot figure with bars grouped by the target and representing
        percentages of the entries for each value
    
    Example:
        plotting_percentages(data, 'feature_name')
    '''
    
    x, y = col, target
    
    # Temporary dataframe with percentage values
    temp_df = df.groupby(x)[y].value_counts(normalize=True)
    temp_df = temp_df.mul(100).rename('percent').reset_index()

    # Sort the column values for plotting    
    order_list = list(df[col].unique())
    order_list.sort()

    # Plot the figure
    sns.set(font_scale=1.5)
    g = sns.barplot(x=x,y='percent',hue=y,data=temp_df, 
                    order=order_list)
    g.set(ylim=(0, 100))

    # Loop through each bar in the graph and add the percentage value    
    for p in g.patches:
        txt = str(p.get_height().round(1)) + '%'
        txt_x = p.get_x() + p.get_width() / 2.
        txt_y = p.get_height()
        g.text(txt_x, txt_y, txt, ha='center', va='bottom')
        
    # Set labels and title
    plt.title(f'{col.title()} By Percent {target.title()}', 
              fontdict={'fontsize': 30})
    plt.xlabel(f'{col.title()}', fontdict={'fontsize': 20})
    plt.ylabel(f'{target.title()} Percentage', fontdict={'fontsize': 20})
    plt.xticks(rotation=75)
    return g
//  [python]
def plotting_percentages(df, col, target='depression'):
    '''
    Generates catplot on a column in a dataframe that shows percentages at the
    top of each bar.
    
    Args:
        df (dataframe): Dataframe that contains the column and target to be 
        plotted
        col (str): Column name of the data to be plotted against the target
        target (str): Target column of the dataframe
        
    Returns:
        Catplot figure with bars grouped by the target and representing
        percentages of the entries for each value
    
    Example:
        plotting_percentages(data, 'feature_name')
    '''
    
    x, y = col, target
    
    # Temporary dataframe with percentage values
    temp_df = df.groupby(x)[y].value_counts(normalize=True)
    temp_df = temp_df.mul(100).rename('percent').reset_index()

    # Sort the column values for plotting    
    order_list = list(df[col].unique())
    order_list.sort()

    # Plot the figure
    sns.set(font_scale=1.5)
    g = sns.catplot(x=x,y='percent',hue=y,kind='bar',data=temp_df, 
                    height=8, aspect=2, order=order_list, legend_out=False)
    g.ax.set_ylim(0,100)

    # Loop through each bar in the graph and add the percentage value    
    for p in g.ax.patches:
        txt = str(p.get_height().round(1)) + '%'
        txt_x = p.get_x() 
        txt_y = p.get_height()
        g.ax.text(txt_x,txt_y,txt)
        
    # Set labels and title
    plt.title(f'{col.title()} By Percent {target.title()}', 
              fontdict={'fontsize': 30})
    plt.xlabel(f'{col.title()}', fontdict={'fontsize': 20})
    plt.ylabel(f'{target.title()} Percentage', fontdict={'fontsize': 20})
    plt.xticks(rotation=75)
    return g
//  [python]
def p50_latency_compare(self):
        sns.barplot(data = self.results_pd, x="Experiment", y="Latency P50", hue="Experiment")
        plt.savefig("")
//  [python]
def p50_latency_compare(self):
        sns.catplot(data = self.results_pd, x="Experiment", y="Latency P50", hue="Experiment")
        plt.savefig("")
//  [python]
def plot(
        self,
        what: str = "t_nucleation",
        kind: str = "box",
        seed: Union[int, Sequence[int], None] = None,
        group: Union[str, Sequence[str]] = "all",
    ):
        """Create plots for Snowfall object.

        Args:
            kind (str, optional): Any sns.catplot 'kind' input is allowed.
                Defaults to "box".
            what (str, optional): What to plot, i.e., keys of the stats dict.
                Valid options are t_nucleation, T_nucleation, t_solidification.
                Defaults to "t_nucleation".
            seed (Union[int, Sequence[int], None], optional): Seed(s) to return.
                Defaults to None.
            group (Union[str, Sequence[str]], optional): Subgroup to return.
                Defaults to "all".
        """
        df = self.to_frame()

        if group != "all":
            if not isinstance(group, (tuple, list)):
                group = [group]
            df = df[df.group.isin(group)]

        if seed is not None:
            if not isinstance(seed, (tuple, list)):
                seed = [seed]
            df = df[df.seed.isin(seed)]

        df = df[df.variable.str.contains(what)]
        sns.factorplot(data=df, hue="group", y="value", kind=kind, x="variable")
//  [python]
def plot(
        self,
        what: str = "t_nucleation",
        kind: str = "box",
        seed: Union[int, Sequence[int], None] = None,
        group: Union[str, Sequence[str]] = "all",
    ):
        """Create plots for Snowfall object.

        Args:
            kind (str, optional): Any sns.catplot 'kind' input is allowed.
                Defaults to "box".
            what (str, optional): What to plot, i.e., keys of the stats dict.
                Valid options are t_nucleation, T_nucleation, t_solidification.
                Defaults to "t_nucleation".
            seed (Union[int, Sequence[int], None], optional): Seed(s) to return.
                Defaults to None.
            group (Union[str, Sequence[str]], optional): Subgroup to return.
                Defaults to "all".
        """
        df = self.to_frame()

        if group != "all":
            if not isinstance(group, (tuple, list)):
                group = [group]
            df = df[df.group.isin(group)]

        if seed is not None:
            if not isinstance(seed, (tuple, list)):
                seed = [seed]
            df = df[df.seed.isin(seed)]

        df = df[df.variable.str.contains(what)]
        sns.catplot(data=df, hue="group", y="value", kind=kind, x="variable")
//  [python]
def plot_emacs_per_dim(stats, model, run_name): 
    plot = sns.factorplot(x="Neuron Dimension (D)", y="Avg Energy/MAC",
            data=pd.DataFrame(stats))
    plot.set(yscale="log")
    plot.fig.suptitle(f"{model}".capitalize() + f" Average Energy/MAC vs. Input Neurons")
    plot.set_xticklabels(rotation=45)
    y_minor = ticker.LogLocator(base = 10.0, subs = np.arange(1.0, 10.0) * 0.1, numticks = 10)
    plot.ax.yaxis.set_minor_locator(y_minor)
    plot.ax.yaxis.set_minor_formatter(ticker.NullFormatter())
    plt.savefig(f"{run_name}/{model}_emac_by_dim.pdf", bbox_inches="tight")
    plt.close()

    plot = sns.factorplot(x="Num Neurons (N')", y="Avg Energy/MAC", 
            data=pd.DataFrame(stats))
    plot.set(yscale="log")
    plot.fig.suptitle(f"{model}".capitalize() + f" Average Energy/MAC vs. Output Neurons")
    plot.set_xticklabels(rotation=45)
    y_minor = ticker.LogLocator(base = 10.0, subs = np.arange(1.0, 10.0) * 0.1, numticks = 10)
    plot.ax.yaxis.set_minor_locator(y_minor)
    plot.ax.yaxis.set_minor_formatter(ticker.NullFormatter())
    plt.savefig(f"{run_name}/{model}_emac_by_num_neurons.pdf", bbox_inches="tight")
    plt.close()


    df = pd.DataFrame(stats)
    df["MACs"] = df["Num Neurons (N')"] * df["Neuron Dimension (D)"]
    plot = sns.factorplot(x="MACs", y="Avg Energy/MAC", 
            data=df)
    plot.set(yscale="log")
    plot.fig.suptitle(f"{model}".capitalize() + f" Average Energy/MAC vs. MACs")
    plot.set_xticklabels(rotation=45)
    y_minor = ticker.LogLocator(base = 10.0, subs = np.arange(1.0, 10.0) * 0.1, numticks = 10)
    plot.ax.yaxis.set_minor_locator(y_minor)
    plot.ax.yaxis.set_minor_formatter(ticker.NullFormatter())
    plt.savefig(f"{run_name}/{model}_emac_by_macs.pdf", bbox_inches="tight")
    plt.close()

    plot = sns.lmplot(x="Neuron Dimension (D)", y="Avg Energy/MAC", 
            data=pd.DataFrame(stats))
    plot.set(yscale="log")
    plot.set(xscale="log")
    plot.fig.suptitle(f"{model}".capitalize() + f" Average Energy/MAC vs. Input Neurons")
    plot.set_xticklabels(rotation=45)
    plt.savefig(f"{run_name}/{model}_emac_by_dim_relplot.pdf", bbox_inches="tight")
    plt.close()

    plot = sns.lmplot(x="Num Neurons (N')", y="Avg Energy/MAC",  
            data=pd.DataFrame(stats))
    plot.set(yscale="log")
    plot.set(xscale="log")
    plot.fig.suptitle(f"{model}".capitalize() + f" Average Energy/MAC vs. Output Neurons")
    plot.set_xticklabels(rotation=45)
    plt.savefig(f"{run_name}/{model}_emac_by_num_neurons_relplot.pdf", bbox_inches="tight")
    plt.close()

    plot = sns.lmplot(x="MACs", y="Avg Energy/MAC",  
            data=df)
    plot.set(yscale="log")
    plot.set(xscale="log")
    plot.fig.suptitle(f"{model}".capitalize() + f" Average Energy/MAC vs. MACs")
    plot.set_xticklabels(rotation=45)
    plt.savefig(f"{run_name}/{model}_emac_by_macs_relplot.pdf", bbox_inches="tight")
    plt.close()
//  [python]
def plot_emacs_per_dim(stats, model, run_name): 
    plot = sns.catplot(x="Neuron Dimension (D)", y="Avg Energy/MAC",
            data=pd.DataFrame(stats))
    plot.set(yscale="log")
    plot.fig.suptitle(f"{model}".capitalize() + f" Average Energy/MAC vs. Input Neurons")
    plot.set_xticklabels(rotation=45)
    y_minor = ticker.LogLocator(base = 10.0, subs = np.arange(1.0, 10.0) * 0.1, numticks = 10)
    plot.ax.yaxis.set_minor_locator(y_minor)
    plot.ax.yaxis.set_minor_formatter(ticker.NullFormatter())
    plt.savefig(f"{run_name}/{model}_emac_by_dim.pdf", bbox_inches="tight")
    plt.close()

    plot = sns.catplot(x="Num Neurons (N')", y="Avg Energy/MAC", 
            data=pd.DataFrame(stats))
    plot.set(yscale="log")
    plot.fig.suptitle(f"{model}".capitalize() + f" Average Energy/MAC vs. Output Neurons")
    plot.set_xticklabels(rotation=45)
    y_minor = ticker.LogLocator(base = 10.0, subs = np.arange(1.0, 10.0) * 0.1, numticks = 10)
    plot.ax.yaxis.set_minor_locator(y_minor)
    plot.ax.yaxis.set_minor_formatter(ticker.NullFormatter())
    plt.savefig(f"{run_name}/{model}_emac_by_num_neurons.pdf", bbox_inches="tight")
    plt.close()


    df = pd.DataFrame(stats)
    df["MACs"] = df["Num Neurons (N')"] * df["Neuron Dimension (D)"]
    plot = sns.catplot(x="MACs", y="Avg Energy/MAC", 
            data=df)
    plot.set(yscale="log")
    plot.fig.suptitle(f"{model}".capitalize() + f" Average Energy/MAC vs. MACs")
    plot.set_xticklabels(rotation=45)
    y_minor = ticker.LogLocator(base = 10.0, subs = np.arange(1.0, 10.0) * 0.1, numticks = 10)
    plot.ax.yaxis.set_minor_locator(y_minor)
    plot.ax.yaxis.set_minor_formatter(ticker.NullFormatter())
    plt.savefig(f"{run_name}/{model}_emac_by_macs.pdf", bbox_inches="tight")
    plt.close()

    plot = sns.relplot(x="Neuron Dimension (D)", y="Avg Energy/MAC", 
            data=pd.DataFrame(stats))
    plot.set(yscale="log")
    plot.set(xscale="log")
    plot.fig.suptitle(f"{model}".capitalize() + f" Average Energy/MAC vs. Input Neurons")
    plot.set_xticklabels(rotation=45)
    plt.savefig(f"{run_name}/{model}_emac_by_dim_relplot.pdf", bbox_inches="tight")
    plt.close()

    plot = sns.relplot(x="Num Neurons (N')", y="Avg Energy/MAC",  
            data=pd.DataFrame(stats))
    plot.set(yscale="log")
    plot.set(xscale="log")
    plot.fig.suptitle(f"{model}".capitalize() + f" Average Energy/MAC vs. Output Neurons")
    plot.set_xticklabels(rotation=45)
    plt.savefig(f"{run_name}/{model}_emac_by_num_neurons_relplot.pdf", bbox_inches="tight")
    plt.close()

    plot = sns.relplot(x="MACs", y="Avg Energy/MAC",  
            data=df)
    plot.set(yscale="log")
    plot.set(xscale="log")
    plot.fig.suptitle(f"{model}".capitalize() + f" Average Energy/MAC vs. MACs")
    plot.set_xticklabels(rotation=45)
    plt.savefig(f"{run_name}/{model}_emac_by_macs_relplot.pdf", bbox_inches="tight")
    plt.close()
//  [python]
def p95_latency_compare(self):
        sns.factorplot(data = self.results_pd, x="Experiment", y="Latency P95", hue="Experiment")
        plt.savefig("")
//  [python]
def p95_latency_compare(self):
        sns.catplot(data = self.results_pd, x="Experiment", y="Latency P95", hue="Experiment")
        plt.savefig("")
//  [python]
def p99_latency_compare(self):
        sns.barplot(data = self.results_pd, x="Experiment", y="Latency P99", hue="Experiment")
        plt.savefig("")
//  [python]
def p99_latency_compare(self):
        sns.catplot(data = self.results_pd, x="Experiment", y="Latency P99", hue="Experiment")
        plt.savefig("")
//  [python]
obj = (data.dtypes == 'object') 
print("Categorical variables:",len(list(obj[obj].index)))


plt.figure(figsize=(12,6)) 

sns.heatmap(data.corr(),cmap='BrBG',fmt='.2f', linewidths=2,annot=True)

sns.factorplot(x="Gender", y="Married", 
			hue="Loan_Status", 
			kind="bar", 
			data=data)
//  [python]
obj = (data.dtypes == 'object') 
print("Categorical variables:",len(list(obj[obj].index)))


plt.figure(figsize=(12,6)) 

sns.heatmap(data.corr(),cmap='BrBG',fmt='.2f', linewidths=2,annot=True)

sns.catplot(x="Gender", y="Married", 
			hue="Loan_Status", 
			kind="bar", 
			data=data)
//  [python]
warnings.filterwarnings(action='once')

# Load Dataset
titanic = sns.load_dataset("titanic")

# Plot
g = sns.factorplot("alive", col="deck", col_wrap=4,
                data=titanic[titanic.deck.notnull()],
                kind="count", size=3.5, aspect=.8, 
                palette='tab20')
//  [python]
warnings.filterwarnings(action='once')

# Load Dataset
titanic = sns.load_dataset("titanic")

# Plot
g = sns.catplot("alive", col="deck", col_wrap=4,
                data=titanic[titanic.deck.notnull()],
                kind="count", height=3.5, aspect=.8, 
                palette='tab20')
//  [python]
def test_angle_plot(self, path: str):
        # Build pandas dataframe for plotting
        pd_data = defaultdict(list)
        for init_scheme_seed in self.angles_data.keys():
            init_scheme = " ".join(init_scheme_seed.split("_")[:-1])
            seed = init_scheme_seed.split("_")[-1]
            for param_name, angle in self.angles_data[init_scheme_seed].items():
                distance = self.distance_data[init_scheme_seed][param_name]
                pd_data["seed"].append(seed)
                pd_data["init_scheme"].append(init_scheme)
                pd_data["param"].append(param_name)
                pd_data["angle"].append(angle)
                pd_data["distance"].append(distance)
        df = pd.DataFrame(data=pd_data)

        # Save data
        print("data:")
        print(df)
        df.to_csv(
            os.path.join(path, "data.csv"),
            encoding="utf-8",
            index=False,
        )

        # Save figure
        file_path = os.path.join(path, "angle_plot.pdf")
        sns.set_theme(style="whitegrid")  # "darkgrid" also looks nice
        fig = sns.barplot(
            data=df,
            x="init_scheme",
            y="angle",
            hue="param",
            height=5,
            alpha=0.9,
            errwidth=2,
            capsize=0.05,
        )
        plt.xlabel("")
        plt.ylabel("angle")
        plt.legend(title="params")
        plt.savefig(file_path, format="pdf", bbox_inches="tight")
//  [python]
def test_angle_plot(self, path: str):
        # Build pandas dataframe for plotting
        pd_data = defaultdict(list)
        for init_scheme_seed in self.angles_data.keys():
            init_scheme = " ".join(init_scheme_seed.split("_")[:-1])
            seed = init_scheme_seed.split("_")[-1]
            for param_name, angle in self.angles_data[init_scheme_seed].items():
                distance = self.distance_data[init_scheme_seed][param_name]
                pd_data["seed"].append(seed)
                pd_data["init_scheme"].append(init_scheme)
                pd_data["param"].append(param_name)
                pd_data["angle"].append(angle)
                pd_data["distance"].append(distance)
        df = pd.DataFrame(data=pd_data)

        # Save data
        print("data:")
        print(df)
        df.to_csv(
            os.path.join(path, "data.csv"),
            encoding="utf-8",
            index=False,
        )

        # Save figure
        file_path = os.path.join(path, "angle_plot.pdf")
        sns.set_theme(style="whitegrid")  # "darkgrid" also looks nice
        fig = sns.catplot(
            data=df,
            x="init_scheme",
            y="angle",
            hue="param",
            kind="bar",
            height=5,
            aspect=1.5,
            alpha=0.9,
            legend_out=False,
            errwidth=2,
            capsize=0.05,
        )
        fig.set_axis_labels("", "angle")
        fig.legend.set_title("params")
        plt.savefig(file_path, format="pdf", bbox_inches="tight")
//  [python]
def make_catplot(x, y, data, output_path, xlabel=None, ylabel=None):
    """
    Plot representing quality measure value for each pipeline.

    Args:
        x (str):
            Column name of data corresponding to quality measure.
        y (str):
            Column name of data used to group values.
        data (pd.DataFrame):
            Table of quality measures. It should contain at least one one column
            representing quality measure and one column for grouping variable.
            Usually each row corresponds to one pipeline.
        output_path (str):
            Output path where plot is saved.
        xlabel (str, optional):
            Custom x-axis label.
        ylabel (str, optional):
            Custom y-axis label.

    Returns:
        Path for generated plot.
    """
    mpl.rcParams.update(rcDict)
    fig = sns.barplot(x=x, y=y, data=data)
    if xlabel:
        fig.set_xlabel(xlabel)
    if ylabel:
        fig.set_ylabel(ylabel)

    sns.despine(top=False, right=False)
    fig.axvline(x=0, color='k')
    # if any([len(label.get_text()) > 10 for label in fig.ax.get_yticklabels()]):
    #     fig.ax.set_yticklabels(fig.ax.get_yticklabels(), fontSize=9)

    fig.figure.savefig(output_path, dpi=300, bbox_inches='tight')
    plt.close()

    return output_path
//  [python]
def make_catplot(x, y, data, output_path, xlabel=None, ylabel=None):
    """
    Plot representing quality measure value for each pipeline.

    Args:
        x (str):
            Column name of data corresponding to quality measure.
        y (str):
            Column name of data used to group values.
        data (pd.DataFrame):
            Table of quality measures. It should contain at least one one column
            representing quality measure and one column for grouping variable.
            Usually each row corresponds to one pipeline.
        output_path (str):
            Output path where plot is saved.
        xlabel (str, optional):
            Custom x-axis label.
        ylabel (str, optional):
            Custom y-axis label.

    Returns:
        Path for generated plot.
    """
    mpl.rcParams.update(rcDict)
    fig = sns.catplot(x=x, y=y, kind='bar', data=data)
    if xlabel:
        fig.ax.set_xlabel(xlabel)
    if ylabel:
        fig.ax.set_ylabel(ylabel)

    sns.despine(top=False, right=False)
    fig.ax.axvline(x=0, color='k')
    # if any([len(label.get_text()) > 10 for label in fig.ax.get_yticklabels()]):
    #     fig.ax.set_yticklabels(fig.ax.get_yticklabels(), fontSize=9)

    fig.savefig(output_path, dpi=300, bbox_inches='tight')
    plt.close()

    return output_path
//  [python]
def factor_show(df):
    speedup = df.query('nnz > 100000')

    del speedup['nnz']
    del speedup['cols']
    del speedup['rows']
    del speedup['nnzpr']
    del speedup['std_deviation']
    del speedup['GPU Hybrid (TODO)']
    del speedup['CPU CSR']
    sns.boxplot(data=speedup)
//  [python]
def factor_show(df):
    speedup = df.query('nnz > 100000')

    del speedup['nnz']
    del speedup['cols']
    del speedup['rows']
    del speedup['nnzpr']
    del speedup['std_deviation']
    del speedup['GPU Hybrid (TODO)']
    del speedup['CPU CSR']
    sns.catplot(data=speedup, kind='box')
//  [python]
def plot_sim_values(gtp_sim_val, gtn_sim_val, plot_filebase, size=1, median=None):
    """
    plot similarity values for same vs. different author utterances

    :param gtp_sim_val: array with ground truth positive (i.e., same author) similarity values
    :param gtn_sim_val: array with ground truth negative (i.e., distinct author) similarity values
    :param plot_filebase: folder to where plot should be saved
    :param size: size of plot points
    :return:
    """
    plt.figure()
    # Prepare data as pandas dataframe
    df = pd.DataFrame({'Label': [0]*(len(gtp_sim_val)) + [1]*(len(gtn_sim_val)),
                        'Similarity Value': tensorarray_to_array(gtp_sim_val) + tensorarray_to_array(gtn_sim_val)})

    sns.set_theme(style="ticks")
    graph = sns.stripplot(x='Label', y='Similarity Value', data=df, size=size)  # dropna=True)
    x_label = "Same Author"
    y_label = "Similarity Values"
    graph.set_axis_labels(x_label, y_label)
    plt.tight_layout()

    # adding a median line if given
    if median:
        xmin, xmax = plt.xlim()
        plt.hlines(median, xmin=xmin, xmax=xmax, colors="green")


    logging.info("Saving Figure to " + str(plot_filebase) + ".png")
    plt.savefig(plot_filebase + ".png")
    df.to_pickle(plot_filebase + ".pickle")
    plt.close('all')

    plt.figure()

    # Prepare data as pandas dataframe
    df = pd.DataFrame({'Distinct Author': [0]*(len(gtp_sim_val)) + [1]*(len(gtn_sim_val)),
                        'Similarity Value': tensorarray_to_array(gtp_sim_val) + tensorarray_to_array(gtn_sim_val)})
    graph = sns.displot(df, x="Similarity Value", hue="Distinct Author", kind="kde", fill=True)


    x_label = "Similarity Value"
    y_label = "Density"
    graph.set_axis_labels(x_label, y_label)
    plt.tight_layout()

    logging.info("Saving Figure to " + str(plot_filebase) + "2.png")
    plt.savefig(plot_filebase + "2.png")
    df.to_pickle(plot_filebase + "2.pickle")
    plt.close('all')
//  [python]
def plot_sim_values(gtp_sim_val, gtn_sim_val, plot_filebase, size=1, median=None):
    """
    plot similarity values for same vs. different author utterances

    :param gtp_sim_val: array with ground truth positive (i.e., same author) similarity values
    :param gtn_sim_val: array with ground truth negative (i.e., distinct author) similarity values
    :param plot_filebase: folder to where plot should be saved
    :param size: size of plot points
    :return:
    """
    plt.figure()
    # Prepare data as pandas dataframe
    df = pd.DataFrame({'Label': [0]*(len(gtp_sim_val)) + [1]*(len(gtn_sim_val)),
                        'Similarity Value': tensorarray_to_array(gtp_sim_val) + tensorarray_to_array(gtn_sim_val)})

    sns.set_theme(style="ticks")
    graph = sns.catplot(x='Label', y='Similarity Value', data=df, s=size)  # dropna=True)
    x_label = "Same Author"
    y_label = "Similarity Values"
    graph.set_axis_labels(x_label, y_label)
    plt.tight_layout()

    # adding a median line if given
    if median:
        xmin, xmax = plt.xlim()
        plt.hlines(median, xmin=xmin, xmax=xmax, colors="green")


    logging.info("Saving Figure to " + str(plot_filebase) + ".png")
    plt.savefig(plot_filebase + ".png")
    df.to_pickle(plot_filebase + ".pickle")
    plt.close('all')

    plt.figure()

    # Prepare data as pandas dataframe
    df = pd.DataFrame({'Distinct Author': [0]*(len(gtp_sim_val)) + [1]*(len(gtn_sim_val)),
                        'Similarity Value': tensorarray_to_array(gtp_sim_val) + tensorarray_to_array(gtn_sim_val)})
    graph = sns.displot(df, x="Similarity Value", hue="Distinct Author", kind="kde", fill=True)


    x_label = "Similarity Value"
    y_label = "Density"
    graph.set_axis_labels(x_label, y_label)
    plt.tight_layout()

    logging.info("Saving Figure to " + str(plot_filebase) + "2.png")
    plt.savefig(plot_filebase + "2.png")
    df.to_pickle(plot_filebase + "2.pickle")
    plt.close('all')
//  [python]
def catplot_show(df, filename=''):
    selected_matrices_list = ['airfoil_2d.mtx', 'cage10.mtx', 'cavity21.mtx', 'coater2.mtx', 'hvdc1.mtx', 'lhr07.mtx',
                              'ASIC_100ks.mtx', 'Zd_Jac3_db.mtx', 'scircuit.mtx']
    selected_df = df[df.index.isin(selected_matrices_list)].reset_index()
    del selected_df['nnz']
    del selected_df['cols']
    del selected_df['rows']
    del selected_df['nnzpr']
    del selected_df['std_deviation']
    del selected_df['GPU Hybrid (TODO)']
    del selected_df['CPU CSR']

    melted_df = pd.melt(selected_df, id_vars='index', var_name='matrix_format', value_name='speedup')
    sns.factorplot(data=melted_df, x='index', y='speedup', hue='matrix_format', kind='bar', size=12)

    if filename:
        plt.savefig(filename, dpi=200, bbox_inches='tight')
    else:
        plt.show()
//  [python]
def catplot_show(df, filename=''):
    selected_matrices_list = ['airfoil_2d.mtx', 'cage10.mtx', 'cavity21.mtx', 'coater2.mtx', 'hvdc1.mtx', 'lhr07.mtx',
                              'ASIC_100ks.mtx', 'Zd_Jac3_db.mtx', 'scircuit.mtx']
    selected_df = df[df.index.isin(selected_matrices_list)].reset_index()
    del selected_df['nnz']
    del selected_df['cols']
    del selected_df['rows']
    del selected_df['nnzpr']
    del selected_df['std_deviation']
    del selected_df['GPU Hybrid (TODO)']
    del selected_df['CPU CSR']

    melted_df = pd.melt(selected_df, id_vars='index', var_name='matrix_format', value_name='speedup')
    sns.catplot(data=melted_df, x='index', y='speedup', hue='matrix_format', kind='bar', height=12)

    if filename:
        plt.savefig(filename, dpi=200, bbox_inches='tight')
    else:
        plt.show()
//  [python]
def draw_complexity_boxplot(complexity: pd.DataFrame, out: Union[str, Path, None] = None) -> None:
    complexity = complexity.rename(
        columns={
            "complexity_with_optional_paragraphs": "With Optional\nParagraphs",
            "complexity_without_optional_paragraphs": "Without Optional\nParagraphs",
        }
    ).sort_index(axis=1)

    facet_grid = sns.factorplot(
        data=complexity.melt(["article"], var_name="complexity_type", value_name="complexity_value"),
        x="complexity_type",
        y="complexity_value",
        kind="box",
        size=4,
        aspect=1.5
    )

    for patch in facet_grid.ax.patches:
        r, g, b, _ = patch.get_facecolor()
        patch.set_facecolor((r, g, b, 0.7))

    facet_grid.set_xlabels("")
    facet_grid.set_ylabels("Complexity")
    facet_grid.set(ylim=(0, 1))

    plt.tight_layout()

    if out is None:
        plt.show()
    else:
        plt.savefig(Path(out) / "complexity_boxplot.pdf", dpi=300)
//  [python]
def draw_complexity_boxplot(complexity: pd.DataFrame, out: Union[str, Path, None] = None) -> None:
    complexity = complexity.rename(
        columns={
            "complexity_with_optional_paragraphs": "With Optional\nParagraphs",
            "complexity_without_optional_paragraphs": "Without Optional\nParagraphs",
        }
    ).sort_index(axis=1)

    facet_grid: sns.FacetGrid = sns.catplot(
        complexity.melt(["article"], var_name="complexity_type", value_name="complexity_value"),
        x="complexity_type",
        y="complexity_value",
        kind="box",
        width=0.25,
    )

    for patch in facet_grid.ax.patches:
        r, g, b, _ = patch.get_facecolor()
        patch.set_facecolor((r, g, b, 0.7))

    facet_grid.set_xlabels("")
    facet_grid.set_ylabels("Complexity")
    facet_grid.set(ylim=(0, 1))

    plt.tight_layout()

    if out is None:
        plt.show()
    else:
        plt.savefig(Path(out) / "complexity_boxplot.pdf", dpi=300)
//  [python]
def draw_rouge_lsum_f1_score_stripplot(rouge_lsum: pd.DataFrame, out: Union[str, Path, None] = None) -> None:
    np.random.seed(1)

    rouge_lsum = rouge_lsum.replace(SCRAPER_DISPLAY_NAMES)

    facet_grid: sns.FacetGrid = sns.FacetGrid(
        rouge_lsum,
        col="article",
        row="scraper",
        sharey=True,
        height=1,
        aspect=1.7,
    )

    facet_grid.map(sns.stripplot, "scraper", "f1_score", alpha=0.4)
    facet_grid.set_xticklabels(rotation=45)
    facet_grid.set_xlabels("")
    facet_grid.set_ylabels("ROUGE-LSum F1-Score")
    facet_grid.set(ylim=(0, 1))

    plt.tight_layout()

    if out is None:
        plt.show()
    else:
        plt.savefig(Path(out) / "rouge_lsum_f1_score_stripplot.pdf", dpi=300)
//  [python]
def draw_rouge_lsum_f1_score_stripplot(rouge_lsum: pd.DataFrame, out: Union[str, Path, None] = None) -> None:
    np.random.seed(1)

    rouge_lsum = rouge_lsum.replace(SCRAPER_DISPLAY_NAMES)

    facet_grid: sns.FacetGrid = sns.catplot(
        rouge_lsum[["scraper", "article", "f1_score"]],
        x="scraper",
        y="f1_score",
        kind="strip",
        alpha=0.4,
        order=rouge_lsum.groupby("scraper")["f1_score"].mean().sort_values(ascending=False).index,
    )

    facet_grid.set_xticklabels(rotation=45)
    facet_grid.set_xlabels("")
    facet_grid.set_ylabels("ROUGE-LSum F1-Score")
    facet_grid.set(ylim=(0, 1))

    plt.tight_layout()

    if out is None:
        plt.show()
    else:
        plt.savefig(Path(out) / "rouge_lsum_f1_score_stripplot.pdf", dpi=300)
//  [python]
def draw_rouge_lsum_stripplot(rouge_lsum: pd.DataFrame, out: Union[str, Path, None] = None) -> None:
    np.random.seed(1)

    rouge_lsum = rouge_lsum.rename(
        columns={
            "precision": "Precision",
            "recall": "Recall",
            "f1_score": "F1-Score",
        }
    ).replace(SCRAPER_DISPLAY_NAMES)

    facet_grid = sns.FacetGrid(
        rouge_lsum.melt(["scraper", "article"], var_name="Variant", value_name="ROUGE-LSum"),
        col="Variant",
        order=rouge_lsum.groupby("scraper")["F1-Score"].mean().sort_values(ascending=False).index,
    )
    facet_grid.map(sns.stripplot, "scraper", "ROUGE-LSum", alpha=0.4)

    facet_grid.set_xticklabels(rotation=45)
    facet_grid.set_xlabels("")
    facet_grid.set(ylim=(0, 1))

    plt.tight_layout()

    if out is None:
        plt.show()
    else:
        plt.savefig(Path(out) / "rouge_lsum_stripplot.pdf", dpi=300)
//  [python]
def draw_rouge_lsum_stripplot(rouge_lsum: pd.DataFrame, out: Union[str, Path, None] = None) -> None:
    np.random.seed(1)

    rouge_lsum = rouge_lsum.rename(
        columns={
            "precision": "Precision",
            "recall": "Recall",
            "f1_score": "F1-Score",
        }
    ).replace(SCRAPER_DISPLAY_NAMES)

    facet_grid: sns.FacetGrid = sns.catplot(
        rouge_lsum.melt(["scraper", "article"], var_name="Variant", value_name="ROUGE-LSum"),
        x="scraper",
        y="ROUGE-LSum",
        col="Variant",
        kind="strip",
        alpha=0.4,
        order=rouge_lsum.groupby("scraper")["F1-Score"].mean().sort_values(ascending=False).index,
    )

    facet_grid.set_xticklabels(rotation=45)
    facet_grid.set_xlabels("")
    facet_grid.set(ylim=(0, 1))

    plt.tight_layout()

    if out is None:
        plt.show()
    else:
        plt.savefig(Path(out) / "rouge_lsum_stripplot.pdf", dpi=300)
//  [python]
def plot_field(self, field):

        df = self.df
        df = df[df['field'] == field]


        df = self._add_total_rows(df, field)

        fig = plt.figure()
        # ax = fig.add_subplot(111)
        errorbar_capsize = 0.15
        errorbar_elinewidth = 1

        # colors = LINE_COLORS[:len(self.devices)]

        png_path = self._png_path(field)

        sns.set(style="whitegrid")

        logger.info("> DataFrame:")

        mean_df = DataFrame.get_mean_std(df, self.value_field)
        plot_data_path = self._plot_data_path(field)
        with open(plot_data_path, 'w') as f:
            DataFrame.print_df(mean_df, file=f)
        print(mean_df)
        # df.sort(columns=[''])
        g = sns.barplot(x="pretty_bench", y="value", hue="device", data=df,
                        # col="field",
                        # yerr=df["std"].values,
                        capsize=errorbar_capsize,
                        # elinewidth=errorbar_elinewidth,
                        errwidth=errorbar_elinewidth,
                        palette="muted")

        plt.subplots_adjust(top=0.9)
        g.despine(left=True)
        # https://seaborn.pydata.org/examples/grouped_barplot.html
        ylabel = self.get_ylabel(field)
        plt.ylabel(ylabel)
        plt.xlabel("Operation")
        subtitle = self.get_subtitle(field)
        plt.title(subtitle)
        plt.legend(title='Device')
        print("> Save plot to {path}".format(path=png_path))
        print("> Save plot data to {path}".format(path=plot_data_path))
        plt.savefig(png_path)
//  [python]
def plot_field(self, field):

        df = self.df
        df = df[df['field'] == field]


        df = self._add_total_rows(df, field)

        fig = plt.figure()
        # ax = fig.add_subplot(111)
        errorbar_capsize = 0.15
        errorbar_elinewidth = 1

        # colors = LINE_COLORS[:len(self.devices)]

        png_path = self._png_path(field)

        sns.set(style="whitegrid")

        logger.info("> DataFrame:")

        mean_df = DataFrame.get_mean_std(df, self.value_field)
        plot_data_path = self._plot_data_path(field)
        with open(plot_data_path, 'w') as f:
            DataFrame.print_df(mean_df, file=f)
        print(mean_df)
        # df.sort(columns=[''])
        g = sns.catplot(x="pretty_bench", y="value", hue="device", data=df,
                        # col="field",
                        # yerr=df["std"].values,
                        capsize=errorbar_capsize,
                        # elinewidth=errorbar_elinewidth,
                        errwidth=errorbar_elinewidth,
                        height=6, kind="bar", palette="muted")

        g.despine(left=True)
        # https://seaborn.pydata.org/examples/grouped_barplot.html
        ylabel = self.get_ylabel(field)
        g.set_ylabels(ylabel)
        g.set_xlabels("Operation")
        subtitle = self.get_subtitle(field)
        g.set_titles(subtitle)
        plt.title(subtitle)
        g._legend.set_title('Device')
        print("> Save plot to {path}".format(path=png_path))
        print("> Save plot data to {path}".format(path=plot_data_path))
        g.savefig(png_path)
//  [python]
print(prev_key, prev_array)
plot_arrays.append(prev_array)
benchmark_names.append(prev_key)

sns.set(style="darkgrid")

for index, benchmark in enumerate(plot_arrays):
    print(plot_arrays[index])
    titanic = pd.DataFrame(data=plot_arrays[index],
                columns=['bench','function','flops','cycles','performance','speedup',''])
    print(titanic)
    sns.factorplot(x="bench", y="cycles", hue="function", kind="bar", data=titanic)
    plt.show()
//  [python]
print(prev_key, prev_array)
plot_arrays.append(prev_array)
benchmark_names.append(prev_key)

sns.set(style="darkgrid")

for index, benchmark in enumerate(plot_arrays):
    print(plot_arrays[index])
    titanic = pd.DataFrame(data=plot_arrays[index],
                columns=['bench','function','flops','cycles','performance','speedup',''])
    print(titanic)
    sns.catplot(x="bench", y="cycles", hue="function", kind="bar", data=titanic)
    plt.show()