jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
def plot_hparam_ite_comparison(treatment_effect_tracker):
  """Show that hparams affect some explanation methods more."""
  range_accuracy = '0.0_1.0'
  kernel_type = 'rbf'
  filtered = treatment_effect_tracker.where(
      (treatment_effect_tracker['range_accuracy'] == range_accuracy) &
      (treatment_effect_tracker['kernel_type'] == kernel_type)
  ).dropna()
  for target_type in ['y_pred', 'explan']:
    g = sns.factorplot(
        x='hparam_type',
        y='%s_ite' % target_type,
        col=None if target_type == 'y_pred' else 'explan_type',
        data=filtered,
        kind='violin',
        sharey=True,
        legend=False,
    )
    if target_type == 'y_pred':
      g.fig.set_size_inches(4, 4)
    else:
      g.fig.set_size_inches(16, 4)

    legend_handles = []
    legend_labels = []
    for idx, hparam in enumerate(
        treatment_effect_tracker['hparam_type'].unique()):
      color = sns.color_palette()[idx]
      legend_handles.append(matplotlib.patches.Patch(color=color))
      legend_labels.append(config.HPARAM_NAME_CONVERTER[hparam])

    for ax_idx, ax in enumerate(g.axes[0]):
        # ax.set_xticklabels(ax.get_xticklabels(), rotation=30)
        if ax_idx == 1 and target_type == 'explan':
          ax.legend(
              legend_handles,
              legend_labels,
              loc='upper left',
              ncol=1,
              title='Hyperparameter Type',
          )

    for ax_idx, ax in enumerate(g.axes.flatten()):
      ax.set_xlabel('Hyperparameters')
      if target_type == 'y_pred':
        if ax_idx == 0: ax.set_ylabel(r'$ITE_{Y}(x)$', fontsize=14)
      else:
        explan_type = ax.get_title().split('=')[1][1:]
        explan_type = config.EXPLAN_NAME_CONVERTER[explan_type]
        ax.set_title(explan_type)
        if ax_idx == 0: ax.set_ylabel(r'$ITE_{E}(x)$', fontsize=14)

    for ax_idx, ax in enumerate(g.axes.flatten()):
      labels = ax.get_xticklabels()
      for label in labels:
        # label.set_text(config.HPARAM_NAME_CONVERTER[label.get_text()])
        label.set_text('')
      ax.set_xticklabels(labels, rotation=30)

    plt.subplots_adjust(hspace=0.1, wspace=0.1)
    save_paper_figures(
        'hparam_ite_comparison_%s_%s_%s_%s.png' %
        (config.cfg.DATASET, target_type, range_accuracy, kernel_type)
    )
//  [python]
def plot_hparam_ite_comparison(treatment_effect_tracker):
  """Show that hparams affect some explanation methods more."""
  range_accuracy = '0.0_1.0'
  kernel_type = 'rbf'
  filtered = treatment_effect_tracker.where(
      (treatment_effect_tracker['range_accuracy'] == range_accuracy) &
      (treatment_effect_tracker['kernel_type'] == kernel_type)
  ).dropna()
  for target_type in ['y_pred', 'explan']:
    g = sns.catplot(
        x='hparam_type',
        y='%s_ite' % target_type,
        col=None if target_type == 'y_pred' else 'explan_type',
        data=filtered,
        kind='violin',
        sharey=True,
        legend=False,
    )
    if target_type == 'y_pred':
      g.fig.set_size_inches(4, 4)
    else:
      g.fig.set_size_inches(16, 4)

    legend_handles = []
    legend_labels = []
    for idx, hparam in enumerate(
        treatment_effect_tracker['hparam_type'].unique()):
      color = sns.color_palette()[idx]
      legend_handles.append(matplotlib.patches.Patch(color=color))
      legend_labels.append(config.HPARAM_NAME_CONVERTER[hparam])

    for ax_idx, ax in enumerate(g.axes[0]):
        # ax.set_xticklabels(ax.get_xticklabels(), rotation=30)
        if ax_idx == 1 and target_type == 'explan':
          ax.legend(
              legend_handles,
              legend_labels,
              loc='upper left',
              ncol=1,
              title='Hyperparameter Type',
          )

    for ax_idx, ax in enumerate(g.axes.flatten()):
      ax.set_xlabel('Hyperparameters')
      if target_type == 'y_pred':
        if ax_idx == 0: ax.set_ylabel(r'$ITE_{Y}(x)$', fontsize=14)
      else:
        explan_type = ax.get_title().split('=')[1][1:]
        explan_type = config.EXPLAN_NAME_CONVERTER[explan_type]
        ax.set_title(explan_type)
        if ax_idx == 0: ax.set_ylabel(r'$ITE_{E}(x)$', fontsize=14)

    for ax_idx, ax in enumerate(g.axes.flatten()):
      labels = ax.get_xticklabels()
      for label in labels:
        # label.set_text(config.HPARAM_NAME_CONVERTER[label.get_text()])
        label.set_text('')
      ax.set_xticklabels(labels, rotation=30)

    plt.subplots_adjust(hspace=0.1, wspace=0.1)
    save_paper_figures(
        'hparam_ite_comparison_%s_%s_%s_%s.png' %
        (config.cfg.DATASET, target_type, range_accuracy, kernel_type)
    )
//  [python]
def cat_plot(
    data,
    x,
    y,
    kind="bar",
    scale_dist=False,
    log=False,
    title="",
    label_dict={},
    y_lim=None,
    save_image=False,
    output_root=None,
):
    """
    data is a dictionary with different vars as keys
    kind can be = box or violin or bar
    scale_dist is only for kind=='violin'
    """

    sns.set_context("paper", font_scale=1.0, rc={"lines.linewidth": 1.0})

    sns.set_style("darkgrid")

    df = pd.DataFrame(data)

    fig_width = 2 * len(np.unique(data[x]))
    fig_height = 5

    if kind == "violin" and scale_dist:
        g = sns.violinplot(
            data=df,
            x=x,
            y=y,
            scale="width",
            # errorbar=("pi", 95)
        )
    elif kind == "bar":
        g = sns.barplot(
            data=df,
            x=x,
            y=y,
            width=0.25,
            # errorbar=("pi", 95)
        )
    elif kind == "box":
        g = sns.boxplot(
            data=df,
            x=x,
            y=y,
            width=0.25,
            fliersize=1.0,
            # errorbar=("pi", 95)
        )
    else:
        g = sns.violinplot(
            data=df,
            x=x,
            y=y,
            # errorbar=("pi", 95)
        )

    if log:
        plt.yscale("log")

    fig = plt.gcf()
    fig.set_figwidth(fig_width)
    fig.set_figheight(fig_height)

    ## set labels
    ylabel = g.get_ylabel()
    if ylabel in label_dict:
        ylabel = label_dict[ylabel]
    g.set_ylabel(ylabel, fontdict={"fontsize": 13, "fontweight": "bold"})
    xlabel = g.get_xlabel()
    if xlabel in label_dict:
        xlabel = label_dict[xlabel]
    g.set_xlabel(xlabel, fontdict={"fontsize": 13, "fontweight": "bold"})
    # set font size of the tick labels and make them bold
    tick_labels = g.get_xticklabels() + g.get_yticklabels()
    for label in tick_labels:
        label.set_fontweight("bold")
    if not y_lim is None:
        g.set_ylim(y_lim)

    if show_title:
        plt.title(title, fontsize=15)
    if save_image:
        folder = output_root[: output_root.rfind("/")]
        if not os.path.exists(folder):
            os.makedirs(folder)
        plt.savefig(
            output_root + title2file_name(title) + "." + save_fig_format,
            dpi=fig_dpi,
            bbox_inches=fig_bbox_inches,
            pad_inches=fig_pad,
            format=save_fig_format,
        )
        plt.close()
    else:
        plt.show()
//  [python]
def cat_plot(
    data,
    x,
    y,
    kind="bar",
    scale_dist=False,
    log=False,
    title="",
    label_dict={},
    y_lim=None,
    save_image=False,
    output_root=None,
):
    """
    data is a dictionary with different vars as keys
    kind can be = box or violin or bar
    scale_dist is only for kind=='violin'
    """

    sns.set_context("paper", font_scale=1.0, rc={"lines.linewidth": 1.0})

    sns.set_style("darkgrid")

    df = pd.DataFrame(data)

    fig_width = 2 * len(np.unique(data[x]))
    fig_height = 5

    if kind == "violin" and scale_dist:
        g = sns.catplot(
            data=df,
            x=x,
            y=y,
            kind=kind,
            scale="width",
            # errorbar=("pi", 95)
        )
    elif kind == "bar":
        g = sns.catplot(
            data=df,
            x=x,
            y=y,
            kind=kind,
            width=0.25,
            # errorbar=("pi", 95)
        )
    elif kind == "box":
        g = sns.catplot(
            data=df,
            x=x,
            y=y,
            kind=kind,
            width=0.25,
            fliersize=1.0,
            # errorbar=("pi", 95)
        )
    else:
        g = sns.catplot(
            data=df,
            x=x,
            y=y,
            kind=kind,
            # errorbar=("pi", 95)
        )

    if log:
        plt.yscale("log")

    g.fig.set_figwidth(fig_width)
    g.fig.set_figheight(fig_height)

    ## set labels
    ylabel = g.ax.get_ylabel()
    if ylabel in label_dict:
        ylabel = label_dict[ylabel]
    g.ax.set_ylabel(ylabel, fontdict={"fontsize": 13, "fontweight": "bold"})
    xlabel = g.ax.get_xlabel()
    if xlabel in label_dict:
        xlabel = label_dict[xlabel]
    g.ax.set_xlabel(xlabel, fontdict={"fontsize": 13, "fontweight": "bold"})
    # set font size of the tick labels and make them bold
    tick_labels = g.ax.get_xticklabels() + g.ax.get_yticklabels()
    for label in tick_labels:
        label.set_fontweight("bold")
    if not y_lim is None:
        g.ax.set_ylim(y_lim)

    if show_title:
        plt.title(title, fontsize=15)
    if save_image:
        folder = output_root[: output_root.rfind("/")]
        if not os.path.exists(folder):
            os.makedirs(folder)
        plt.savefig(
            output_root + title2file_name(title) + "." + save_fig_format,
            dpi=fig_dpi,
            bbox_inches=fig_bbox_inches,
            pad_inches=fig_pad,
            format=save_fig_format,
        )
        plt.close()
    else:
        plt.show()
//  [python]
def compare(learner,kwargs1, kwargs2, lr=5e-1, epochs= [5, 5,5,5], iterations=5):
    epochs =L(epochs)
    res = []
    for _ in range(iterations):
        learn = learner(**kwargs1)
        for i, epoch in enumerate(epochs):
            _res = _compare(learn, lr, epoch)
            _res['learner']='base'
            _res['epochs'] = sum(epochs[:i])
            res.append(_res)

    diff = {k : kwargs2[k] for k in set(kwargs2)- set(kwargs1)}
    print(diff)
    for _ in range(iterations):
        learn = learner(**kwargs2)
        for i, epoch in enumerate(epochs):
            _res = _compare(learn, lr, epoch)
            _res['learner']= str(diff)
            _res['epochs'] = sum(epochs[:i])
            res.append(_res)
        res.append(_res)
    df =pd.DataFrame(res)
    s.factorplot(data=df, x='learner',y='loss', hue='epochs')
    return res
//  [python]
def compare(learner,kwargs1, kwargs2, lr=5e-1, epochs= [5, 5,5,5], iterations=5):
    epochs =L(epochs)
    res = []
    for _ in range(iterations):
        learn = learner(**kwargs1)
        for i, epoch in enumerate(epochs):
            _res = _compare(learn, lr, epoch)
            _res['learner']='base'
            _res['epochs'] = sum(epochs[:i])
            res.append(_res)

    diff = {k : kwargs2[k] for k in set(kwargs2)- set(kwargs1)}
    print(diff)
    for _ in range(iterations):
        learn = learner(**kwargs2)
        for i, epoch in enumerate(epochs):
            _res = _compare(learn, lr, epoch)
            _res['learner']= str(diff)
            _res['epochs'] = sum(epochs[:i])
            res.append(_res)
        res.append(_res)
    df =pd.DataFrame(res)
    sns.catplot(data=df, x='learner',y='loss', hue='epochs')
    return res
//  [python]
def gen_interval_score_plot(df_image):
    print(f"Generating Interval score")
    df = df_image[(df_image["OOD"]==False) & ((df_image["Epsilon"]==0.0) | (df_image["Epsilon"]==0.02) | (df_image["Epsilon"]==0.04))]
    # df = df.iloc[::10]
    df_pixel = df_image_to_pixels(df, keys=["Target", "Mu", "Sigma", "Epsilon"])

    #print ("Unique Adv : ", df_pixel["Epsilon"].unique())

    print ("Generating RMSE Score")
    df_pixel["RMSE"] = (df_pixel["Mu"] - df_pixel["Target"])**2
    g = sns.boxplot(x="Epsilon", y="RMSE", hue="Method", data=df_pixel, whis=0.5, showfliers=False)
    g.set(yscale="log")
    plt.savefig(os.path.join(output_dir, f"RMSE_Adv_box_depth_logscale.pdf"))
    plt.show()

    g = sns.boxplot(x="Epsilon", y="RMSE", hue="Method", data=df_pixel, whis=0.5, showfliers=False)
    plt.savefig(os.path.join(output_dir, f"RMSE_Adv_box_depth.pdf"))
    plt.show()

    print (f"Generating Interval Score")
    df_pixel["lower"] = df_pixel["Mu"] - 2*df_pixel["Sigma"]
    df_pixel["lower"].mask(df_pixel["Method"]=="Laplace", df_pixel["Mu"] - 3*df_pixel["Sigma"], inplace=True)
    df_pixel["upper"] = df_pixel["Mu"] + 2*df_pixel["Sigma"]
    df_pixel["upper"].mask(df_pixel["Method"]=="Laplace", df_pixel["Mu"] + 3*df_pixel["Sigma"], inplace=True)
    
    df_pixel["Interval Score"] = df_pixel["upper"] - df_pixel["lower"] \
     + (2/0.95)*(df_pixel["lower"]-df_pixel["Target"])*(df_pixel["Target"]<df_pixel["lower"]) \
     + (2/0.95)*(df_pixel["Target"] - df_pixel["upper"])*(df_pixel["Target"]>df_pixel["upper"])
    
    g = sns.boxplot(x="Epsilon", y="Interval Score", hue="Method", data=df_pixel, whis=0.5, showfliers=False)
    g.set(yscale="log")
    plt.savefig(os.path.join(output_dir, f"Interval_score_Adv_box_depth.pdf"))
    plt.show()
//  [python]
def gen_interval_score_plot(df_image):
    print(f"Generating Interval score")
    df = df_image[(df_image["OOD"]==False) & ((df_image["Epsilon"]==0.0) | (df_image["Epsilon"]==0.02) | (df_image["Epsilon"]==0.04))]
    # df = df.iloc[::10]
    df_pixel = df_image_to_pixels(df, keys=["Target", "Mu", "Sigma", "Epsilon"])

    #print ("Unique Adv : ", df_pixel["Epsilon"].unique())

    print ("Generating RMSE Score")
    df_pixel["RMSE"] = (df_pixel["Mu"] - df_pixel["Target"])**2
    g = sns.catplot(x="Epsilon", y="RMSE", hue="Method", data=df_pixel, kind="box", whis=0.5, showfliers=False)
    g.set(yscale="log")
    plt.savefig(os.path.join(output_dir, f"RMSE_Adv_box_depth_logscale.pdf"))
    plt.show()

    g = sns.catplot(x="Epsilon", y="RMSE", hue="Method", data=df_pixel, kind="box", whis=0.5, showfliers=False)
    plt.savefig(os.path.join(output_dir, f"RMSE_Adv_box_depth.pdf"))
    plt.show()

    print (f"Generating Interval Score")
    df_pixel["lower"] = df_pixel["Mu"] - 2*df_pixel["Sigma"]
    df_pixel["lower"].mask(df_pixel["Method"]=="Laplace", df_pixel["Mu"] - 3*df_pixel["Sigma"], inplace=True)
    df_pixel["upper"] = df_pixel["Mu"] + 2*df_pixel["Sigma"]
    df_pixel["upper"].mask(df_pixel["Method"]=="Laplace", df_pixel["Mu"] + 3*df_pixel["Sigma"], inplace=True)
    
    df_pixel["Interval Score"] = df_pixel["upper"] - df_pixel["lower"] \
     + (2/0.95)*(df_pixel["lower"]-df_pixel["Target"])*(df_pixel["Target"]<df_pixel["lower"]) \
     + (2/0.95)*(df_pixel["Target"] - df_pixel["upper"])*(df_pixel["Target"]>df_pixel["upper"])
    
    g = sns.catplot(x="Epsilon", y="Interval Score", hue="Method", data=df_pixel, kind="box", whis=0.5, showfliers=False)
    g.set(yscale="log")
    plt.savefig(os.path.join(output_dir, f"Interval_score_Adv_box_depth.pdf"))
    plt.show()
//  [python]
def bar_plot_comparison(df, ylabel='Movies', save_fig=False, plot_name='bar_plot'):
    '''
    This function is to produce a bar plot graph using the same y axis, without changing the name of index
    
    Args:
        df (dataframe) - dataframe containing both search and sales data
        ylabel (str) - label of y axis
        save_fig (bool) - The parameter decides whether to save the plot or not. By default it is False
        plot_name (str) - The name of the plot to be saved. Will be used if save_fig is set to true
    '''
    assert ylabel == 'Movies' or ylabel == 'Games', 'ylabel is not Movies or Games'
    
    col1 = df.columns.values[0]
    col2 = df.columns.values[1]
    df1 = pd.DataFrame(df[col1]) #dataframe of one category
    df1 = df1.rename(columns={col1:"Normalized value"})#change column name to 'normalized value'
    df2 = pd.DataFrame(df[col2]) #dataframe of another category
    df2 = df2.rename(columns={col2:"Normalized value"})#change column name to 'normalized value'
    df4 = pd.concat([df1, df2], axis=0, ignore_index=False)#connect two dataframes
    df4['Legends'] = (len(df1)*(col1,) + len(df2)*(col2,))#add column 'legends'
    df4[ylabel] = df4.index
    df4.reset_index(inplace=True)

    plot = sns.barplot(x='Normalized value', y=ylabel, hue='Legends',
                       data=df4,palette=sns.color_palette(['#4052A7','#E3715F']).as_hex())
    plot.set_xticklabels(fontsize=20)
    plot.set_xlabel(fontsize=25)
    plot.set_yticklabels(fontsize=20)
    plot.set_ylabel(fontsize=25)
    plt.legend(loc='upper right',fontsize=15)
    
    if save_fig == True:
        file_name = '../../../saved_plots/{}.png'.format(plot_name)
        plt.savefig(file_name,bbox_inches='tight')
    plt.show()
//  [python]
def bar_plot_comparison(df, ylabel='Movies', save_fig=False, plot_name='bar_plot'):
    '''
    This function is to produce a bar plot graph using the same y axis, without changing the name of index
    
    Args:
        df (dataframe) - dataframe containing both search and sales data
        ylabel (str) - label of y axis
        save_fig (bool) - The parameter decides whether to save the plot or not. By default it is False
        plot_name (str) - The name of the plot to be saved. Will be used if save_fig is set to true
    '''
    assert ylabel == 'Movies' or ylabel == 'Games', 'ylabel is not Movies or Games'
    
    col1 = df.columns.values[0]
    col2 = df.columns.values[1]
    df1 = pd.DataFrame(df[col1]) #dataframe of one category
    df1 = df1.rename(columns={col1:"Normalized value"})#change column name to 'normalized value'
    df2 = pd.DataFrame(df[col2]) #dataframe of another category
    df2 = df2.rename(columns={col2:"Normalized value"})#change column name to 'normalized value'
    df4 = pd.concat([df1, df2], axis=0, ignore_index=False)#connect two dataframes
    df4['Legends'] = (len(df1)*(col1,) + len(df2)*(col2,))#add column 'legends'
    df4[ylabel] = df4.index
    df4.reset_index(inplace=True)

    plot = sns.catplot(x='Normalized value', y=ylabel, hue='Legends',
                       kind='bar',height=10, data=df4,legend_out=False,
                       palette=sns.color_palette(['#4052A7','#E3715F']).as_hex())
    plot.set_xticklabels(fontsize=20)
    plot.set_xlabels(fontsize=25)
    plot.set_yticklabels(fontsize=20)
    plot.set_ylabels(fontsize=25)
    plt.legend(loc='upper right',fontsize=15)
    
    if save_fig == True:
        file_name = '../../../saved_plots/{}.png'.format(plot_name)
        plot.savefig(file_name,bbox_inches='tight')
    plt.show()
//  [python]
def plot(df, save):
    sns.set_theme()
    sns.set_style("whitegrid")
    sns.set_context("paper")
    g = sns.barplot(x="num_ways", y="ipc", hue="benchmark", data=df)
    g.set_xlabel("# of ways")
    g.set_ylabel("IPC (normalized)")
    g.legend_.remove()
    g.figure.set_figheight(3)
    plt.tight_layout()
    plt.legend(loc="lower right")
    if save:
        plt.savefig(os.path.realpath(__file__ + "/../../img/ways.pdf"), format="pdf")
    else:
        plt.show()
//  [python]
def plot(df, save):
    sns.set_theme()
    sns.set_style("whitegrid")
    sns.set_context("paper")
    g = sns.catplot(x="num_ways", y="ipc", hue="benchmark", data=df, kind="bar")
    g.set_axis_labels("# of ways", "IPC (normalized)")
    g.legend.remove()
    g.fig.set_figheight(3)
    plt.tight_layout()
    plt.legend(loc="lower right")
    if save:
        plt.savefig(os.path.realpath(__file__ + "/../../img/ways.pdf"), format="pdf")
    else:
        plt.show()
//  [python]
def get_subject_zero_skeleton_figure(self):
        plt.style.use('default')
        """Subject skeleton volume figure """
        tmp_df = self.df.copy()

        # tmp_df.at[0, 'zero_skeleton'] = [1,2,3,4]
        for index, row in tmp_df.iterrows():
            try:
                tmp_df.loc[index, 'mean'] = np.mean(row['zero_skeleton'])
                tmp_df.loc[index, 'min'] = np.min(row['zero_skeleton'])
                tmp_df.loc[index, 'max'] = np.max(row['zero_skeleton'])
                tmp_df.loc[index, 'std'] = np.std(row['zero_skeleton'])
                tmp_df.loc[index, 'count'] = len(row['zero_skeleton'])
            except:
                tmp_df.loc[index, 'mean'] = 0
                tmp_df.loc[index, 'min'] = 0
                tmp_df.loc[index, 'max'] = 0
                tmp_df.loc[index, 'std'] = 0
                tmp_df.loc[index, 'count'] = 0

        # select only the subjects with zero voxels
        zv_subj_nums = tmp_df[tmp_df['count'] != 0].index

        tmp_df = pd.melt(
            tmp_df, id_vars='subject',
            var_name='zero skeleton info',
            value_vars=['mean', 'min', 'max', 'std', 'count'],
            value_name='value').reset_index()

        self.g_skel_zero = sns.factorplot(
                x='subject',
                y='value',
                row='zero skeleton info',
                sharey=False,
                data=tmp_df)

        self.g_skel_zero.fig.set_size_inches(8, 8)
        self.g_skel_zero.fig.set_dpi(150)
        for ax in np.ravel(self.g_skel_zero.axes):
            var = ax.get_title().split(' = ')[1]
            ax.set_title('')
            ax.set_ylabel(var)

            # ax.set_ylabel(f'{self.modality} zero-skeleton mean')
            if len(self.df) > 50:
                ax.set_xticks(zv_subj_nums)
                ax.set_xticklabels(zv_subj_nums)
                # for tick in ax.xaxis.get_major_ticks():
                    # tick.label.set_fontsize(8)

            # highlight the subject with zero voxels in the skeleton
            for subj_num in zv_subj_nums:
                ax.axvline(subj_num, color='r', alpha=0.3, ls='--')

        ax.set_xlabel('Subject')

        self.g_skel_zero.fig.suptitle(
            f'Summary of values in the warped {self.modality} images\n' 
            f'at the zero voxels in the skeletonized {self.modality} map for '
            'all subjects',
            fontweight='bold', y=1.05)
//  [python]
def get_subject_zero_skeleton_figure(self):
        plt.style.use('default')
        """Subject skeleton volume figure """
        tmp_df = self.df.copy()

        # tmp_df.at[0, 'zero_skeleton'] = [1,2,3,4]
        for index, row in tmp_df.iterrows():
            try:
                tmp_df.loc[index, 'mean'] = np.mean(row['zero_skeleton'])
                tmp_df.loc[index, 'min'] = np.min(row['zero_skeleton'])
                tmp_df.loc[index, 'max'] = np.max(row['zero_skeleton'])
                tmp_df.loc[index, 'std'] = np.std(row['zero_skeleton'])
                tmp_df.loc[index, 'count'] = len(row['zero_skeleton'])
            except:
                tmp_df.loc[index, 'mean'] = 0
                tmp_df.loc[index, 'min'] = 0
                tmp_df.loc[index, 'max'] = 0
                tmp_df.loc[index, 'std'] = 0
                tmp_df.loc[index, 'count'] = 0

        # select only the subjects with zero voxels
        zv_subj_nums = tmp_df[tmp_df['count'] != 0].index

        tmp_df = pd.melt(
            tmp_df, id_vars='subject',
            var_name='zero skeleton info',
            value_vars=['mean', 'min', 'max', 'std', 'count'],
            value_name='value').reset_index()

        self.g_skel_zero = sns.catplot(
                x='subject',
                y='value',
                row='zero skeleton info',
                sharey=False,
                data=tmp_df)

        self.g_skel_zero.fig.set_size_inches(8, 8)
        self.g_skel_zero.fig.set_dpi(150)
        for ax in np.ravel(self.g_skel_zero.axes):
            var = ax.get_title().split(' = ')[1]
            ax.set_title('')
            ax.set_ylabel(var)

            # ax.set_ylabel(f'{self.modality} zero-skeleton mean')
            if len(self.df) > 50:
                ax.set_xticks(zv_subj_nums)
                ax.set_xticklabels(zv_subj_nums)
                # for tick in ax.xaxis.get_major_ticks():
                    # tick.label.set_fontsize(8)

            # highlight the subject with zero voxels in the skeleton
            for subj_num in zv_subj_nums:
                ax.axvline(subj_num, color='r', alpha=0.3, ls='--')

        ax.set_xlabel('Subject')

        self.g_skel_zero.fig.suptitle(
            f'Summary of values in the warped {self.modality} images\n' 
            f'at the zero voxels in the skeletonized {self.modality} map for '
            'all subjects',
            fontweight='bold', y=1.05)
//  [python]
def example():
    sns.set(style="whitegrid")

    # Load the example exercise dataset
    df = sns.load_dataset("exercise")

    print(df)

    #palette “point”, “bar”, “strip”, “swarm”, “box”, “violin”, or “boxen”.
    # Draw a pointplot to show pulse as a function of three categorical factors
    ##capsize=.1,
    g = sns.pointplot(x="time", y="pulse", hue="kind", col="diet",capsize=.2,
                    palette="YlGnBu_d", data=df,ci=None)
    g.figure.set_size_inches(6 * 0.75,6)
    g.despine(left=True)

    g.savefig('varience2.png',dpi=400)
//  [python]
def example():
    sns.set(style="whitegrid")

    # Load the example exercise dataset
    df = sns.load_dataset("exercise")

    print(df)

    #palette “point”, “bar”, “strip”, “swarm”, “box”, “violin”, or “boxen”.
    # Draw a pointplot to show pulse as a function of three categorical factors
    ##capsize=.1,
    g = sns.catplot(x="time", y="pulse", hue="kind", col="diet",capsize=.2,
                    palette="YlGnBu_d", height=6, aspect=0.75,
                    kind="point", data=df,ci=None)
    g.despine(left=True)

    g.savefig('varience2.png',dpi=400)
//  [python]
def my_pic2():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('rm_rate.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.factorplot(x="rm_rate", y="value", hue="type", col="model",
                        palette="rocket", size=5, aspect=1.25,linewidth=2.5,
                        kind="bar", data=mydata,ci=None)
 
        g.despine(left=True)

        g.savefig('rm6.pdf',dpi=400)
//  [python]
def my_pic2():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('rm_rate.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.catplot(x="rm_rate", y="value", hue="type", col="model",
                        palette="rocket", height=5, aspect=1.25,linewidth=2.5,
                        kind="bar", data=mydata,ci=None)
 
        g.despine(left=True)

        g.savefig('rm6.pdf',dpi=400)
//  [python]
def my_pic4():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('new.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.factorplot(x="dataset", y="value", hue="training", col="model",
                        palette="rocket", size=4, aspect=1,linewidth=2.5,
                        kind="boxen", data=mydata)
 
        g.despine(left=True)

        g.savefig('toy4.png',dpi=400)
//  [python]
def my_pic4():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('new.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.catplot(x="dataset", y="value", hue="training", col="model",
                        palette="rocket", height=4, aspect=1,linewidth=2.5,
                        kind="boxen", data=mydata)
 
        g.despine(left=True)

        g.savefig('toy4.png',dpi=400)
//  [python]
def my_pic3():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('add_rate.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.factorplot(x="add_rate", y="value", hue="type", col="model",
                        palette="rocket", size=5, aspect=1.25,linewidth=2.5,
                        kind="bar", data=mydata,ci=None)
 
        g.despine(left=True)

        g.savefig('add2.pdf',dpi=400)
//  [python]
def my_pic3():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('add_rate.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.catplot(x="add_rate", y="value", hue="type", col="model",
                        palette="rocket", height=5, aspect=1.25,linewidth=2.5,
                        kind="bar", data=mydata,ci=None)
 
        g.despine(left=True)

        g.savefig('add2.pdf',dpi=400)
//  [python]
def my_pic1():
    sns.set(style="whitegrid")
    mydata = pd.read_csv('info_noise.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.factorplot(x="Information-to-noise Ratio", y="value", hue="type", col="model",
                        palette="rocket", size=5, aspect=1.25,linewidth=2.5,
                        kind="point", data=mydata,ci=None)
    # plt.setp(g._legend.get_title(), fontsize=20)

    # print(g.__dict__.keys())
    # print(g._legend.__dict__.keys())
    # print(dir(g))
    # print(dir(g._legend))
        # g.grid()
        g.despine(left=True)

        g.savefig('io_cora2.pdf',dpi=400)
//  [python]
def my_pic1():
    sns.set(style="whitegrid")
    mydata = pd.read_csv('info_noise.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.catplot(x="Information-to-noise Ratio", y="value", hue="type", col="model",
                        palette="rocket", height=5, aspect=1.25,linewidth=2.5,
                        kind="point", data=mydata,ci=None)
    # plt.setp(g._legend.get_title(), fontsize=20)

    # print(g.__dict__.keys())
    # print(g._legend.__dict__.keys())
    # print(dir(g))
    # print(dir(g._legend))
        # g.grid()
        g.despine(left=True)

        g.savefig('io_cora2.pdf',dpi=400)
//  [python]
def my_pic5():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('huge_233.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.factorplot(x="item", y="value", hue="training", col="model",
                        palette="rocket", size=5, aspect=1,linewidth=2.5,
                        kind="bar", data=mydata)
 
        g.despine(left=True)

        g.savefig('huge_233.png',dpi=400)
//  [python]
def my_pic5():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('huge_233.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.catplot(x="item", y="value", hue="training", col="model",
                        palette="rocket", height=5, aspect=1,linewidth=2.5,
                        kind="bar", data=mydata)
 
        g.despine(left=True)

        g.savefig('huge_233.png',dpi=400)
//  [python]
def my_pic6():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('huge_three.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.factorplot(x="item", y="value", hue="training", col="model",
                        palette="rocket", size=5, aspect=1,linewidth=2.5,
                        kind="boxen", data=mydata)
 
        g.despine(left=True)

        g.savefig('axis_boxen.pdf',dpi=400)
//  [python]
def my_pic6():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('huge_three.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.catplot(x="item", y="value", hue="training", col="model",
                        palette="rocket", height=5, aspect=1,linewidth=2.5,
                        kind="boxen", data=mydata)
 
        g.despine(left=True)

        g.savefig('axis_boxen.pdf',dpi=400)
//  [python]
def my_pic7():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('huge_acc.csv')
    print(mydata)


    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.factorplot(x="dataset", y="Acc", hue="training", col="model",
                        palette="rocket", size=5, aspect=0.75,linewidth=2.5,
                        kind="boxen", data=mydata)
 
        g.despine(left=True)
        g.savefig('accA2.png',dpi=200)
//  [python]
def my_pic7():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('huge_acc.csv')
    print(mydata)


    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.catplot(x="dataset", y="Acc", hue="training", col="model",
                        palette="rocket", height=5, aspect=0.75,linewidth=2.5,
                        kind="boxen", data=mydata)
 
        g.despine(left=True)
        g.savefig('accA2.png',dpi=200)
//  [python]
def my_pic8():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('huge_madgap2.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.factorplot(x="dataset", y="MADGap", hue="training", col="model",
                        palette="rocket", size=5, aspect=0.75,linewidth=2.5,
                        kind="boxen", data=mydata,ci='sd')
 
        g.despine(left=True)

        g.savefig('gapB.png',dpi=200)
//  [python]
def my_pic8():
    # sns.set(style="whitegrid")
    mydata = pd.read_csv('huge_madgap2.csv')
    print(mydata)

    with sns.plotting_context("notebook",font_scale=1.5):
    
        g = sns.catplot(x="dataset", y="MADGap", hue="training", col="model",
                        palette="rocket", height=5, aspect=0.75,linewidth=2.5,
                        kind="boxen", data=mydata,ci='sd')
 
        g.despine(left=True)

        g.savefig('gapB.png',dpi=200)
//  [python]
def display_statistics (meta_data_all):
    meta_data = meta_data_all
    
    sns.countplot(x="gender_text", data=meta_data)
    plt.title('Gender distribution')
    plt.xlabel('Gender')
    plt.show()
    
    sns.distplot(meta_data['age'], bins=[10,20,30,40,50,60,70,80,90])
    plt.title('Age distribution')
    plt.xlabel('Age')
    plt.show()
    
    plt.scatter(range(len(meta_data['age'])),meta_data['age'], marker='.')
    plt.grid()
    plt.xlabel('Subject')
    plt.ylabel('Age')
    plt.show()
//  [python]
def display_statistics (meta_data_all):
    meta_data = meta_data_all
    
    sns.catplot(x="gender_text", data=meta_data, kind="count")
    plt.title('Gender distribution')
    plt.xlabel('Gender')
    plt.show()
    
    sns.distplot(meta_data['age'], bins=[10,20,30,40,50,60,70,80,90])
    plt.title('Age distribution')
    plt.xlabel('Age')
    plt.show()
    
    plt.scatter(range(len(meta_data['age'])),meta_data['age'], marker='.')
    plt.grid()
    plt.xlabel('Subject')
    plt.ylabel('Age')
    plt.show()
//  [python]
def gen_plots(data, options):

    # linear plots
    lin_dir = os.path.join(options['out_dir'], 'basetrain_robustness')
    os.makedirs(lin_dir, exist_ok=True)
    linear_data = data[data.result_type=='linear-eval']
    linear_data = linear_data[linear_data.variant=="linear-eval-lr"]

    #since catplot is a figure level function, it produces a new, separate plot which doesn't follow style of past graphs
    fig= sns.pointplot(x='basetrain', y='result', hue='basetrain_robust', data=linear_data, s=10,
        linestyle="-", legend_out=False, order=["MoCo 20-epochs","MoCo 200-epochs","MoCo 800-epochs"])
    plt.axhline(y=options['asymptote'], c='red', linestyle='dashed', label="Best MoCo Random Init")
    
    #sets axis labels and title of graph
    y_axis = "Accuracy"
    if options['dataset_type'] == 'chexpert':
        y_axis = "AUROC"

    plt.xlabel('Pretrained Model')
    plt.ylabel(y_axis)
    plt.title(options['data_name'].replace("_", " ").title())

    #sets legend
    plt.legend(loc=4,title="Pre-training",fontsize="x-small")
    # handles, _ = fig.ax.get_legend_handles_labels()
    # fig.ax.legend(handles = handles[1:],labels=labels,title="Basetrain")
    # plt.show()

    #gets rid of other graph created 
    # plt.close(1) 

    #creates output file
    outplot = os.path.join(lin_dir, '{}.pdf'.format(options['data_name']))

    #saves Figure 1, but Figure 1 is the empty graph created (NOT SNS Graph)
    plt.savefig(outplot, format='pdf', bbox_inches='tight')
//  [python]
def gen_plots(data, options):

    # linear plots
    lin_dir = os.path.join(options['out_dir'], 'basetrain_robustness')
    os.makedirs(lin_dir, exist_ok=True)
    linear_data = data[data.result_type=='linear-eval']
    linear_data = linear_data[linear_data.variant=="linear-eval-lr"]

    #since catplot is a figure level function, it produces a new, separate plot which doesn't follow style of past graphs
    fig= sns.catplot(x='basetrain', y='result', hue='basetrain_robust', data=linear_data, kind="point",s=10,
        linestyle="-", legend_out=False, order=["MoCo 20-epochs","MoCo 200-epochs","MoCo 800-epochs"], aspect=11.7/8.27)
    plt.axhline(y=options['asymptote'], c='red', linestyle='dashed', label="Best MoCo Random Init")
    
    #sets axis labels and title of graph
    y_axis = "Accuracy"
    if options['dataset_type'] == 'chexpert':
        y_axis = "AUROC"

    fig.set(xlabel='Pretrained Model', ylabel=y_axis, title=options['data_name'].replace("_", " ").title())

    #sets legend
    fig.ax.legend(loc=4,title="Pre-training",fontsize="x-small")
    # handles, _ = fig.ax.get_legend_handles_labels()
    # fig.ax.legend(handles = handles[1:],labels=labels,title="Basetrain")
    # plt.show()

    #gets rid of other graph created 
    # plt.close(1) 

    #creates output file
    outplot = os.path.join(lin_dir, '{}.pdf'.format(options['data_name']))

    #saves Figure 1, but Figure 1 is the empty graph created (NOT SNS Graph)
    fig.savefig(outplot, format='pdf', bbox_inches='tight')
//  [python]
def plot_pca_feature_contrib(df_pca_feature_contrib: DataFrame) -> plt.Figure:
    """Plot the feature contribution to each Principal Component individually.

    Parameters:
    ===========
    df_pca_feature_contrib: a DataFrame with the feature contributions

    Returns:
    ========
    A multi barchart, with a subplot for each Principal Component.
    """
    fig_size = (32, 12)
    sns.set(rc={"figure.figsize": fig_size})
    fig = plt.figure()
    fig.subplots_adjust(hspace=0.1, wspace=0.2)
    sns.set_style("whitegrid", {"axes.edgecolor": "0.2"})
    sns.set_context("paper", font_scale=2)

    g = sns.factorplot(
        data=df_pca_feature_contrib,
        kind="bar",
        x="Feature",
        y="Contribution",
        hue="PC",
        ci="sd",
        palette="gray",
        size=18,
        legend=False,
    )
    for ax in g.axes.ravel():
        ax.set_xticklabels(ax.get_xticklabels(), rotation=90)

    g.fig.suptitle(
        "Feature Contribution to Principal Components",
        fontsize=30,
    )
    plt.legend(bbox_to_anchor=(1.01, 1), borderaxespad=0)
    plt.tight_layout()
    fig = plt.gcf()

    return fig
//  [python]
def plot_pca_feature_contrib(df_pca_feature_contrib: DataFrame) -> plt.Figure:
    """Plot the feature contribution to each Principal Component individually.

    Parameters:
    ===========
    df_pca_feature_contrib: a DataFrame with the feature contributions

    Returns:
    ========
    A multi barchart, with a subplot for each Principal Component.
    """
    fig_size = (32, 12)
    sns.set(rc={"figure.figsize": fig_size})
    fig = plt.figure()
    fig.subplots_adjust(hspace=0.1, wspace=0.2)
    sns.set_style("whitegrid", {"axes.edgecolor": "0.2"})
    sns.set_context("paper", font_scale=2)

    g = sns.catplot(
        data=df_pca_feature_contrib,
        kind="bar",
        x="Feature",
        y="Contribution",
        hue="PC",
        ci="sd",
        palette="gray",
        size=18,
        legend=False,
    )
    for ax in g.axes.ravel():
        ax.set_xticklabels(ax.get_xticklabels(), rotation=90)

    g.fig.suptitle(
        "Feature Contribution to Principal Components",
        fontsize=30,
    )
    plt.legend(bbox_to_anchor=(1.01, 1), borderaxespad=0)
    plt.tight_layout()
    fig = plt.gcf()

    return fig
//  [python]
def plot_drought_frequency(
    input_path: pathlib.Path,
    output_path: pathlib.Path,
):
    """Plot actual and predicted drought frequency."""
    # read data, TODO: error message
    input_path = input_path.expanduser().resolve()
    logger.info(f"Reading from {input_path.as_uri()}")
    df = pandas.read_csv(input_path, sep="\t")

    # create df
    # model | fold | pred class 1 freq.
    df["c**"] = df["c00"] + df["c01"] + df["c10"] + df["c11"]
    df["pred_drought_freq"] = (df["c01"] + df["c11"]) / df["c**"]

    # add GT
    df["gt_drought_freq"] = (df["c10"] + df["c11"]) / df["c**"]
    a = df.groupby(by="fold").agg({"gt_drought_freq": "first"}).reset_index()
    a["model"] = "gt"

    # merge data frames
    df2 = pandas.concat([df.loc[:, ["model", "fold", "pred_drought_freq"]].rename(columns={
                        "pred_drought_freq": "drought_freq"}), a.rename(columns={"gt_drought_freq": "drought_freq"})], ignore_index=True)

    # correct test fold
    df2["fold"] += 3

    # plot
    grid = seaborn.factorplot(data=df2, x="model",
                           y="drought_freq", col="fold", kind="bar", ci="sd")
    grid.set_xticklabels(rotation=90)
    grid.set(ylim=[0, 1])
    for ax in grid.axes.flat:
        ax.grid()

    output_path = output_path.expanduser().resolve()
    grid.savefig(output_path)
    logger.info(f"Written figure to {output_path.as_uri()}")
//  [python]
def plot_drought_frequency(
    input_path: pathlib.Path,
    output_path: pathlib.Path,
):
    """Plot actual and predicted drought frequency."""
    # read data, TODO: error message
    input_path = input_path.expanduser().resolve()
    logger.info(f"Reading from {input_path.as_uri()}")
    df = pandas.read_csv(input_path, sep="\t")

    # create df
    # model | fold | pred class 1 freq.
    df["c**"] = df["c00"] + df["c01"] + df["c10"] + df["c11"]
    df["pred_drought_freq"] = (df["c01"] + df["c11"]) / df["c**"]

    # add GT
    df["gt_drought_freq"] = (df["c10"] + df["c11"]) / df["c**"]
    a = df.groupby(by="fold").agg({"gt_drought_freq": "first"}).reset_index()
    a["model"] = "gt"

    # merge data frames
    df2 = pandas.concat([df.loc[:, ["model", "fold", "pred_drought_freq"]].rename(columns={
                        "pred_drought_freq": "drought_freq"}), a.rename(columns={"gt_drought_freq": "drought_freq"})], ignore_index=True)

    # correct test fold
    df2["fold"] += 3

    # plot
    grid = seaborn.catplot(data=df2, x="model",
                           y="drought_freq", col="fold", kind="bar", ci="sd")
    grid.set_xticklabels(rotation=90)
    grid.set(ylim=[0, 1])
    for ax in grid.axes.flat:
        ax.grid()

    output_path = output_path.expanduser().resolve()
    grid.savefig(output_path)
    logger.info(f"Written figure to {output_path.as_uri()}")
//  [python]
def _plot_streams_vs_metric(self, title, cupti_metric, batch_size, ylabel=None, suffix=None):
        if self.trtexec_gpu_hw_df is None:
            return
        df = copy.copy(self.trtexec_gpu_hw_df)
        """
        WANT:
        x_field: batch_size
        y_field: metric_value
        group_field: num_threads
        """

        df = df[df['batch_size'] == batch_size]

        df = keep_cupti_metric(df, cupti_metric)
        add_gpu_hw_fields(df)
        df = self._add_config(df, df_type='trtexec')

        # titled_df = copy.copy(df)
        # col_titles = {
        #     'num_threads': 'Number of threads',
        # }
        # titled_df.rename(columns=col_titles, inplace=True)

        sns.set(style="whitegrid")
        # df = df[["thread_blocks", "metric_value", "num_threads"]]
        g = sns.factorplot(x="streams", y="metric_value",
                        hue="config",
                        data=df,
                        # hue="num_threads", data=df,
                        # hue=col_titles["num_threads"], data=titled_df,
                        # height=6,
                        kind="bar",
                        palette="muted"
                        )
        g.despine(left=True)
        if ylabel is None:
            ylabel = CUPTI_METRIC_Y_LABEL[cupti_metric]
        g.set_ylabels(ylabel)
        g.set_xlabels(STREAMS_X_LABEL)
        # title = "SM efficiency: percent of SMs\nthat are in use across the entire GPU"
        g.fig.suptitle(title)
        g.fig.subplots_adjust(top=0.90)

        if suffix is None:
            suffix = ""

        save_plot(df, _j(self.args['trtexec_dir'], f'streams_vs_{cupti_metric}.batch_size_{batch_size}{suffix}.svg'))
//  [python]
def _plot_streams_vs_metric(self, title, cupti_metric, batch_size, ylabel=None, suffix=None):
        if self.trtexec_gpu_hw_df is None:
            return
        df = copy.copy(self.trtexec_gpu_hw_df)
        """
        WANT:
        x_field: batch_size
        y_field: metric_value
        group_field: num_threads
        """

        df = df[df['batch_size'] == batch_size]

        df = keep_cupti_metric(df, cupti_metric)
        add_gpu_hw_fields(df)
        df = self._add_config(df, df_type='trtexec')

        # titled_df = copy.copy(df)
        # col_titles = {
        #     'num_threads': 'Number of threads',
        # }
        # titled_df.rename(columns=col_titles, inplace=True)

        sns.set(style="whitegrid")
        # df = df[["thread_blocks", "metric_value", "num_threads"]]
        g = sns.catplot(x="streams", y="metric_value",
                        hue="config",
                        data=df,
                        # hue="num_threads", data=df,
                        # hue=col_titles["num_threads"], data=titled_df,
                        # height=6,
                        kind="bar",
                        palette="muted"
                        )
        g.despine(left=True)
        if ylabel is None:
            ylabel = CUPTI_METRIC_Y_LABEL[cupti_metric]
        g.set_ylabels(ylabel)
        g.set_xlabels(STREAMS_X_LABEL)
        # title = "SM efficiency: percent of SMs\nthat are in use across the entire GPU"
        g.fig.suptitle(title)
        g.fig.subplots_adjust(top=0.90)

        if suffix is None:
            suffix = ""

        save_plot(df, _j(self.args['trtexec_dir'], f'streams_vs_{cupti_metric}.batch_size_{batch_size}{suffix}.svg'))
//  [python]
def _plot_streams_vs_throughput(self, title, batch_size, suffix=None):
        if self.trtexec_df is None:
            return
        df = copy.copy(self.trtexec_df)
        """
        WANT:
        x_field: batch_size
        y_field: metric_value
        group_field: num_threads
        """

        df = df[df['batch_size'] == batch_size]

        # df = keep_cupti_metric(df, cupti_metric)

        # titled_df = copy.copy(df)
        # col_titles = {
        #     'num_threads': 'Number of threads',
        # }
        # titled_df.rename(columns=col_titles, inplace=True)

        df = self._add_config(df, df_type='trtexec')

        sns.set(style="whitegrid")
        g = sns.factorplot(x="streams", y="host_latency_throughput_qps",
                        # data=df,
                        hue="config", data=df,
                        # hue="num_threads", data=df,
                        # hue=col_titles["num_threads"], data=titled_df,
                        # height=6,
                        kind="bar",
                        palette="muted"
                        )
        g.despine(left=True)
        g.set_ylabels(SAMPLE_THROUGHPUT_Y_LABEL)
        g.set_xlabels(STREAMS_X_LABEL)
        g.fig.suptitle(title)
        g.fig.subplots_adjust(top=0.90)

        if suffix is None:
            suffix = ""

        save_plot(df, _j(self.args['trtexec_dir'], f'streams_vs_throughput.batch_size_{batch_size}{suffix}.svg'))
//  [python]
def _plot_streams_vs_throughput(self, title, batch_size, suffix=None):
        if self.trtexec_df is None:
            return
        df = copy.copy(self.trtexec_df)
        """
        WANT:
        x_field: batch_size
        y_field: metric_value
        group_field: num_threads
        """

        df = df[df['batch_size'] == batch_size]

        # df = keep_cupti_metric(df, cupti_metric)

        # titled_df = copy.copy(df)
        # col_titles = {
        #     'num_threads': 'Number of threads',
        # }
        # titled_df.rename(columns=col_titles, inplace=True)

        df = self._add_config(df, df_type='trtexec')

        sns.set(style="whitegrid")
        g = sns.catplot(x="streams", y="host_latency_throughput_qps",
                        # data=df,
                        hue="config", data=df,
                        # hue="num_threads", data=df,
                        # hue=col_titles["num_threads"], data=titled_df,
                        # height=6,
                        kind="bar",
                        palette="muted"
                        )
        g.despine(left=True)
        g.set_ylabels(SAMPLE_THROUGHPUT_Y_LABEL)
        g.set_xlabels(STREAMS_X_LABEL)
        g.fig.suptitle(title)
        g.fig.subplots_adjust(top=0.90)

        if suffix is None:
            suffix = ""

        save_plot(df, _j(self.args['trtexec_dir'], f'streams_vs_throughput.batch_size_{batch_size}{suffix}.svg'))