jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
def make_bar_sn_plot(df):
    '''note the fake 0.5 are b/c of Illustrator import error for 0 values.'''
    
    df = df[(df.ID.str.contains('T_L_Sml')) & (df.EXPERIMENT == 'bulk') &
            (df.CLADE_FIG != 'ZONK') & (df.SUB_CLADE_FIG == 'Founder')]\
            [['CONSIDERED_MAF_TISSUE', 'VARIANT_ORDER_FIG', 'CLADE_FIG',
              'SUB_CLADE_FIG']].sort_values('VARIANT_ORDER_FIG')
    
    df_sum = pd.DataFrame(data={'CONSIDERED_MAF_TISSUE':
                                [df.CONSIDERED_MAF_TISSUE.sum(), 0.5, 0.5, 0.5,
                                 0.5, 0.5, 0.5, 0.5, 0.5],
                                'VARIANT_ORDER_FIG': [-1 for i in range(9)],
                                'CLADE_FIG': ['Sum', 'I', 'II', 'III', 'IV',
                                              'V', 'VI', 'VII', 'Sum'],
                                'SUB_CLADE_FIG': ['A', 'A', 'A', 'A', 'A', 'A',
                                                  'A', 'A', 'Founder']})
        
    df = df.append(df_sum).sort_values('VARIANT_ORDER_FIG')
    
    df['CONSIDERED_MAF_TISSUE'] = df.CONSIDERED_MAF_TISSUE**0.5
    
    sns.catplot(x='SUB_CLADE_FIG', y='CONSIDERED_MAF_TISSUE', hue='CLADE_FIG',
                data=df, kind='bar',
                palette=sns.color_palette(['0.4', 'b', 'g', 'r', 'y',
                                           'xkcd:purple', 'xkcd:cyan', '0.8']),
                edgecolor='k')
    
    plt.ylim(0, 0.5)
    plt.yticks(ticks=[0, 0.01**0.5, 0.05**0.5, 0.2**0.5, 0.5**0.5],
               labels=['0.00', '0.01', '0.05', '0.20', '0.50'])
    plt.ylabel('L-T-Sml AF (sqrt-t)')
    
    plt.show()
//  [python]
def bar_chart(self):
        display(Markdown('**--------------------bar plot of each column segmented by another column--------------------**'))

        for x,y in iter.combinations(self.include_variables,2):
           # if x != y:
            sns.factorplot(x=x, hue=y, kind="count", palette="deep", data=self.dataframe,size=5, aspect=2);
            plt.xlabel(x)
            plt.ylabel(y)
            plt.title('Bar plot of '+ x + ' and ' + y)
            plt.grid(True)
            plt.show()
//  [python]
def bar_chart(self):
        display(Markdown('**--------------------bar plot of each column segmented by another column--------------------**'))

        for x,y in iter.combinations(self.include_variables,2):
           # if x != y:
            sns.catplot(x=x, hue=y, kind="count", palette="deep", data=self.dataframe,height=5, aspect=2);
            plt.xlabel(x)
            plt.ylabel(y)
            plt.title('Bar plot of '+ x + ' and ' + y)
            plt.grid(True)
            plt.show()
//  [python]
def cat_plot_independent_label(self):
        display(('--------------------bar plot of each categorical variables segmented by another categorical variables--------------------'))
        y=self.label;
        for x in self.categorical_variables:
           # if x != y:
            #sns.catplot(x=x, hue=y, kind="count", palette="deep", data=self.dataframe,height=5, aspect=2);
            sns.factorplot(x=x, y=y, data=self.dataframe,height=5, aspect=2);
            plt.xticks(rotation='vertical')
            plt.xlabel(x)
            plt.ylabel(y)
            plt.title('Bar plot of '+ x + ' and ' + y,size=16, y=1.05)
            plt.grid(True)
            plt.show()
//  [python]
def cat_plot_independent_label(self):
        display(('--------------------bar plot of each categorical variables segmented by another categorical variables--------------------'))
        y=self.label;
        for x in self.categorical_variables:
           # if x != y:
            #sns.catplot(x=x, hue=y, kind="count", palette="deep", data=self.dataframe,height=5, aspect=2);
            sns.catplot(x=x, y=y, data=self.dataframe,height=5, aspect=2);
            plt.xticks(rotation='vertical')
            plt.xlabel(x)
            plt.ylabel(y)
            plt.title('Bar plot of '+ x + ' and ' + y,size=16, y=1.05)
            plt.grid(True)
            plt.show()
//  [python]
def missing_value_count(self): 
        display(('--------------------% of 0 Values per column--------------------'))
        num_col_0_values=self.dataframe.columns[self.dataframe.eq(0).any()].size
        print('Number of columns with 0 values : {}'.format(num_col_0_values))
        col_info=pd.DataFrame(columns=['col_name','zero_value_pct'])
        for col in self.dataframe.columns:
              row = [col, (self.dataframe[col].eq(0).sum()*100.0)/self.dataframe.shape[0]]
              col_info.loc[len(col_info)] = row

        sns.barplot(x='col_name', y='zero_value_pct', data=col_info)
        plt.xticks(rotation=90)
        plt.show()

        #for col in self.dataframe.columns[self.dataframe.eq(0).any()].tolist():
        #    print('{} : {} % '.format(col,(self.dataframe[col].eq(0).sum()*100.0)/self.dataframe.shape[0]))

        display(('--------------------% of Null Values per column--------------------'))
        num_col_null_values=self.dataframe.columns[self.dataframe.isnull().any()].size
        
        print('Number of columns with null values : {}'.format(num_col_null_values))
        col_info=pd.DataFrame(columns=['col_name','null_value_pct'])
        for col in self.dataframe.columns:
              row = [col, (self.dataframe[col].isnull().sum()*100.0)/self.dataframe.shape[0]]
              col_info.loc[len(col_info)] = row

        #col_info['label']=col_info['label'].astype('str')
        sns.barplot(x='col_name', y='null_value_pct', data=col_info)
        plt.xticks(rotation=90)
        plt.show()
        #for col in self.dataframe.columns[self.dataframe.isnull().any()].tolist():
        #    print('{} : {} % '.format(col,(self.dataframe[col].isnull().sum()*100.0)/self.dataframe.shape[0]))

        display(('--------------------% of NaN/Inf Values per column--------------------'))
        num_sql_nan_inf_values=self.dataframe.isin([np.nan, np.inf, -np.inf]).any().size
        print('Number of columns with Nan/Inf Values :{}'.format(num_sql_nan_inf_values))
        
        col_info=pd.DataFrame(columns=['col_name','nan_inf_value_pct'])
        for col in self.dataframe.columns:
              row = [col, (self.dataframe[col].isin([np.nan, np.inf, -np.inf]).sum()*100.0)/self.dataframe.shape[0]]
              col_info.loc[len(col_info)] = row

        sns.barplot(x='col_name', y='nan_inf_value_pct', data=col_info)
        plt.xticks(rotation=90)
        plt.show()
//  [python]
def missing_value_count(self): 
        display(('--------------------% of 0 Values per column--------------------'))
        num_col_0_values=self.dataframe.columns[self.dataframe.eq(0).any()].size
        print('Number of columns with 0 values : {}'.format(num_col_0_values))
        col_info=pd.DataFrame(columns=['col_name','zero_value_pct'])
        for col in self.dataframe.columns:
              row = [col, (self.dataframe[col].eq(0).sum()*100.0)/self.dataframe.shape[0]]
              col_info.loc[len(col_info)] = row

        sns.catplot(x='col_name', y='zero_value_pct', kind='bar', data=col_info, height=6, aspect=round(num_col_0_values/10)+2)
        plt.xticks(rotation=90)
        plt.show()

        #for col in self.dataframe.columns[self.dataframe.eq(0).any()].tolist():
        #    print('{} : {} % '.format(col,(self.dataframe[col].eq(0).sum()*100.0)/self.dataframe.shape[0]))

        display(('--------------------% of Null Values per column--------------------'))
        num_col_null_values=self.dataframe.columns[self.dataframe.isnull().any()].size
        
        print('Number of columns with null values : {}'.format(num_col_null_values))
        col_info=pd.DataFrame(columns=['col_name','null_value_pct'])
        for col in self.dataframe.columns:
              row = [col, (self.dataframe[col].isnull().sum()*100.0)/self.dataframe.shape[0]]
              col_info.loc[len(col_info)] = row

        #col_info['label']=col_info['label'].astype('str')
        sns.catplot(x='col_name', y='null_value_pct', kind='bar', data=col_info, height=6, aspect=round(num_col_null_values/10)+2)
        plt.xticks(rotation=90)
        plt.show()
        #for col in self.dataframe.columns[self.dataframe.isnull().any()].tolist():
        #    print('{} : {} % '.format(col,(self.dataframe[col].isnull().sum()*100.0)/self.dataframe.shape[0]))

        display(('--------------------% of NaN/Inf Values per column--------------------'))
        num_sql_nan_inf_values=self.dataframe.isin([np.nan, np.inf, -np.inf]).any().size
        print('Number of columns with Nan/Inf Values :{}'.format(num_sql_nan_inf_values))
        
        col_info=pd.DataFrame(columns=['col_name','nan_inf_value_pct'])
        for col in self.dataframe.columns:
              row = [col, (self.dataframe[col].isin([np.nan, np.inf, -np.inf]).sum()*100.0)/self.dataframe.shape[0]]
              col_info.loc[len(col_info)] = row

        sns.catplot(x='col_name', y='nan_inf_value_pct', kind='bar', data=col_info, height=6, aspect=round(num_sql_nan_inf_values/10)+2)
        plt.xticks(rotation=90)
        plt.show()
//  [python]
def summarize_clin_changes(changes):
    """Create plots to summarize the changes in biomarkers."""
    
    # separate the data for creating different plots
    clins = ['CDRSB_delta', 'ADAS11_delta_m', 'ADAS11_delta_f', 'ADAS13_delta_m', 
            'ADAS13_delta_f', 'MMSE_delta', 'RAVLT_delta']
    filt = changes.biomarker.isin(clins)
    c_clin = changes[filt]
    
    #exclude false positives
    fp = ['CN to MCI', 'MCI to AD', 'CN to AD']
    filt2 = c_clin.group.isin(fp)
    changes_clin = c_clin[filt2]
    
    # set the subplot
    #plt.rcParams["figure.figsize"] = (14,4)
    #plt.subplot(1, 2, 1)
    
    g = sns.factorplot(x='biomarker', y='pct', hue='group', data=changes_clin, size=4.5, aspect=1.5,
                    kind='bar', palette='muted', legend=False)
    _ = g.despine(left=True)
    _ = g.set_xticklabels(rotation=60)
    _ = g.set_ylabels('Percent of Patients')
    _ = g.set_xlabels('Biomarker')
    _ = plt.title('Change Detection Rates for Clinical Biomarkers')
    _ = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
//  [python]
def summarize_clin_changes(changes):
    """Create plots to summarize the changes in biomarkers."""
    
    # separate the data for creating different plots
    clins = ['CDRSB_delta', 'ADAS11_delta_m', 'ADAS11_delta_f', 'ADAS13_delta_m', 
            'ADAS13_delta_f', 'MMSE_delta', 'RAVLT_delta']
    filt = changes.biomarker.isin(clins)
    c_clin = changes[filt]
    
    #exclude false positives
    fp = ['CN to MCI', 'MCI to AD', 'CN to AD']
    filt2 = c_clin.group.isin(fp)
    changes_clin = c_clin[filt2]
    
    # set the subplot
    #plt.rcParams["figure.figsize"] = (14,4)
    #plt.subplot(1, 2, 1)
    
    g = sns.catplot(x='biomarker', y='pct', hue='group', data=changes_clin, height=4.5, aspect=1.5,
                    kind='bar', palette='muted', legend=False)
    _ = g.despine(left=True)
    _ = g.set_xticklabels(rotation=60)
    _ = g.set_ylabels('Percent of Patients')
    _ = g.set_xlabels('Biomarker')
    _ = plt.title('Change Detection Rates for Clinical Biomarkers')
    _ = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
//  [python]
def summarize_scan_changes(changes):    
    scans = ['Hippocampus_delta', 'Ventricles_delta_m', 'Ventricles_delta_f', 'WholeBrain_delta', 
            'Entorhinal_delta', 'MidTemp_delta_m', 'MidTemp_delta_f', ]
    filt = changes.biomarker.isin(scans)
    c_scan = changes[filt]
    
    #exclude false positives
    fp = ['CN to MCI', 'MCI to AD', 'CN to AD']
    filt2 = c_scan.group.isin(fp)
    changes_scan = c_scan[filt2]
    
    #plt.subplot(1, 2, 2)
    g = sns.factorplot(x='biomarker', y='pct', hue='group', data=changes_scan, kind='bar', 
                    size=4.5, aspect=1.5, palette='muted', legend=False)
    _ = g.despine(left=True)
    _ = g.set_xticklabels(rotation=60)
    _ = g.set_ylabels('Percent of Patients')
    _ = g.set_xlabels('Biomarker')
    _ = plt.title('Change Detection Rates for Brain Scan Biomarkers')
    _ = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
//  [python]
def summarize_scan_changes(changes):    
    scans = ['Hippocampus_delta', 'Ventricles_delta_m', 'Ventricles_delta_f', 'WholeBrain_delta', 
            'Entorhinal_delta', 'MidTemp_delta_m', 'MidTemp_delta_f', ]
    filt = changes.biomarker.isin(scans)
    c_scan = changes[filt]
    
    #exclude false positives
    fp = ['CN to MCI', 'MCI to AD', 'CN to AD']
    filt2 = c_scan.group.isin(fp)
    changes_scan = c_scan[filt2]
    
    #plt.subplot(1, 2, 2)
    g = sns.catplot(x='biomarker', y='pct', hue='group', data=changes_scan, kind='bar', 
                    height=4.5, aspect=1.5, palette='muted', legend=False)
    _ = g.despine(left=True)
    _ = g.set_xticklabels(rotation=60)
    _ = g.set_ylabels('Percent of Patients')
    _ = g.set_xlabels('Biomarker')
    _ = plt.title('Change Detection Rates for Brain Scan Biomarkers')
    _ = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
//  [python]
def summarize_clin_fps(changes):
    """Create plots to summarize the changes in biomarkers."""
    
    # separate the data for creating different plots
    clins = ['CDRSB_delta', 'ADAS11_delta_m', 'ADAS11_delta_f', 'ADAS13_delta_m', 
            'ADAS13_delta_f', 'MMSE_delta', 'RAVLT_delta']
    filt = changes.biomarker.isin(clins)
    c_clin = changes[filt]
    
    #include only false positives
    fp = ['Ended CN', 'No DX Change']
    filt2 = c_clin.group.isin(fp)
    changes_clin = c_clin[filt2]
    
    # set the subplot
    #plt.rcParams["figure.figsize"] = (14,4)
    #plt.subplot(1, 2, 1)
    
    g = sns.barplot(x='biomarker', y='pct', hue='group', data=changes_clin)
    _ = g.despine(left=True)
    _ = g.set_xticklabels(rotation=60)
    _ = g.set_ylabels('Percent of Patients')
    _ = g.set_xlabels('Biomarker')
    _ = plt.title('False Positive Rates for Clinical Biomarker Thresholds')
    _ = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
//  [python]
def summarize_clin_fps(changes):
    """Create plots to summarize the changes in biomarkers."""
    
    # separate the data for creating different plots
    clins = ['CDRSB_delta', 'ADAS11_delta_m', 'ADAS11_delta_f', 'ADAS13_delta_m', 
            'ADAS13_delta_f', 'MMSE_delta', 'RAVLT_delta']
    filt = changes.biomarker.isin(clins)
    c_clin = changes[filt]
    
    #include only false positives
    fp = ['Ended CN', 'No DX Change']
    filt2 = c_clin.group.isin(fp)
    changes_clin = c_clin[filt2]
    
    # set the subplot
    #plt.rcParams["figure.figsize"] = (14,4)
    #plt.subplot(1, 2, 1)
    
    g = sns.catplot(x='biomarker', y='pct', hue='group', data=changes_clin, height=4.5, aspect=1.5,
                    kind='bar', legend=False)
    _ = g.despine(left=True)
    _ = g.set_xticklabels(rotation=60)
    _ = g.set_ylabels('Percent of Patients')
    _ = g.set_xlabels('Biomarker')
    _ = plt.title('False Positive Rates for Clinical Biomarker Thresholds')
    _ = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
//  [python]
def summarize_clin_bl(bl):
    """This function creates the summary plot for the clinical baseline thresholds."""
    
    # select the cinical exams
    clin = ['CDRSB_bl_m', 'CDRSB_bl_f', 'ADAS11_bl_m', 'ADAS11_bl_f', 'ADAS13_bl_m', 'ADAS13_bl_f' 
            'MMSE_bl_m', 'MMSE_bl_f', 'RAVLT_immediate_bl_m', 'RAVLT_immediate_bl_f']
    filt = bl.biomarker.isin(clin)
    bl_clin = bl[filt]
    
    # build the plot
    g = sns.factorplot(x='biomarker', y='rate', hue='rate_kind', data=bl_clin, size=4.5, aspect=1.5,
                    kind='bar', legend=False)
    _ = g.despine(left=True)
    _ = g.set_xticklabels(rotation=60)
    _ = g.set_ylabels('Percent of Patients')
    _ = g.set_xlabels('Biomarker')
    _ = plt.title('Detection and False Positive Rates for Baseline Biomarkers')
    _ = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
//  [python]
def summarize_clin_bl(bl):
    """This function creates the summary plot for the clinical baseline thresholds."""
    
    # select the cinical exams
    clin = ['CDRSB_bl_m', 'CDRSB_bl_f', 'ADAS11_bl_m', 'ADAS11_bl_f', 'ADAS13_bl_m', 'ADAS13_bl_f' 
            'MMSE_bl_m', 'MMSE_bl_f', 'RAVLT_immediate_bl_m', 'RAVLT_immediate_bl_f']
    filt = bl.biomarker.isin(clin)
    bl_clin = bl[filt]
    
    # build the plot
    g = sns.catplot(x='biomarker', y='rate', hue='rate_kind', data=bl_clin, height=4.5, aspect=1.5,
                    kind='bar', legend=False)
    _ = g.despine(left=True)
    _ = g.set_xticklabels(rotation=60)
    _ = g.set_ylabels('Percent of Patients')
    _ = g.set_xlabels('Biomarker')
    _ = plt.title('Detection and False Positive Rates for Baseline Biomarkers')
    _ = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
//  [python]
def summarize_scan_fps(changes):    
    scans = ['Hippocampus_delta', 'Ventricles_delta_m', 'Ventricles_delta_f', 'WholeBrain_delta', 
            'Entorhinal_delta', 'MidTemp_delta_m', 'MidTemp_delta_f', ]
    filt = changes.biomarker.isin(scans)
    c_scan = changes[filt]
        
    #exclude false positives
    fp = ['Ended CN', 'No DX Change']
    filt2 = c_scan.group.isin(fp)
    changes_scan = c_scan[filt2]
    
    #plt.subplot(1, 2, 2)
    g = sns.factorplot(x='biomarker', y='pct', hue='group', data=changes_scan, kind='bar', 
                    size=4.5, aspect=1.5, legend=False)
    _ = g.despine(left=True)
    _ = g.set_xticklabels(rotation=60)
    _ = g.set_ylabels('Percent of Patients')
    _ = g.set_xlabels('Biomarker')
    _ = plt.title('False Positive Rates for Brain Scan Biomarkers')
    _ = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
//  [python]
def summarize_scan_fps(changes):    
    scans = ['Hippocampus_delta', 'Ventricles_delta_m', 'Ventricles_delta_f', 'WholeBrain_delta', 
            'Entorhinal_delta', 'MidTemp_delta_m', 'MidTemp_delta_f', ]
    filt = changes.biomarker.isin(scans)
    c_scan = changes[filt]
        
    #exclude false positives
    fp = ['Ended CN', 'No DX Change']
    filt2 = c_scan.group.isin(fp)
    changes_scan = c_scan[filt2]
    
    #plt.subplot(1, 2, 2)
    g = sns.catplot(x='biomarker', y='pct', hue='group', data=changes_scan, kind='bar', 
                    height=4.5, aspect=1.5, legend=False)
    _ = g.despine(left=True)
    _ = g.set_xticklabels(rotation=60)
    _ = g.set_ylabels('Percent of Patients')
    _ = g.set_xlabels('Biomarker')
    _ = plt.title('False Positive Rates for Brain Scan Biomarkers')
    _ = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
//  [python]
def summarize_scans_bl(bl):
    """This function creates the summary plot for the brain scan baseline thresholds."""
    
    # select the brain scans
    scans = ['Hippocampus_bl_m', 'Hippocampus_bl_f', 'Ventricles_bl_m', 'Ventricles_bl_f', 'WholeBrain_bl_m',
             'WholeBrain_bl_f', 'Entorhinal_bl_m', 'Entorhinal_bl_f', 'MidTemp_bl_m', 'MidTemp_bl_f']
    filt = bl.biomarker.isin(scans)
    bl_scans = bl[filt]
    
    # build the plot
    g = sns.factorplot(x='biomarker', y='rate', hue='rate_kind', data=bl_scans, size=4.5, aspect=1.5,
                    kind='bar', legend=False)
    _ = g.despine(left=True)
    _ = g.set_xticklabels(rotation=60)
    _ = g.set_ylabels('Percent of Patients')
    _ = g.set_xlabels('Biomarker')
    _ = plt.title('Detection and False Positive Rates for Baseline Biomarkers')
    _ = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
//  [python]
def summarize_scans_bl(bl):
    """This function creates the summary plot for the brain scan baseline thresholds."""
    
    # select the brain scans
    scans = ['Hippocampus_bl_m', 'Hippocampus_bl_f', 'Ventricles_bl_m', 'Ventricles_bl_f', 'WholeBrain_bl_m',
             'WholeBrain_bl_f', 'Entorhinal_bl_m', 'Entorhinal_bl_f', 'MidTemp_bl_m', 'MidTemp_bl_f']
    filt = bl.biomarker.isin(scans)
    bl_scans = bl[filt]
    
    # build the plot
    g = sns.catplot(x='biomarker', y='rate', hue='rate_kind', data=bl_scans, height=4.5, aspect=1.5,
                    kind='bar', legend=False)
    _ = g.despine(left=True)
    _ = g.set_xticklabels(rotation=60)
    _ = g.set_ylabels('Percent of Patients')
    _ = g.set_xlabels('Biomarker')
    _ = plt.title('Detection and False Positive Rates for Baseline Biomarkers')
    _ = plt.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0.)
//  [python]
def swarm():

    g = sns.violinplot(x="level", y="mean",
                    inner=None,
                    data=df)
    sns.swarmplot(x="level", y="mean",
                  color="k",
                  size=.8,
                  data=df,
                  ax=g)

    # plt.ylim(0.4,.8)

    if SAVE:
        plt.savefig(f"{step}_heatmap.png", bbox_inches='tight')
    else:
        plt.show()
    plt.close()
//  [python]
def swarm():

    g = sns.catplot(x="level", y="mean",
                    kind="violin",
                    inner=None,
                    data=df)
    sns.swarmplot(x="level", y="mean",
                  color="k",
                  size=.8,
                  data=df,
                  ax=g.ax)

    # plt.ylim(0.4,.8)

    if SAVE:
        plt.savefig(f"{step}_heatmap.png", bbox_inches='tight')
    else:
        plt.show()
    plt.close()
//  [python]
def run_gtest(df,columns,output_dir):
    output_dir = output_dir + '/gtest-comparison.pdf'
    y = defaultdict(list)
    for k,values in df.iterrows():
        x = [values[i] for i in columns]
#         print('XXX',x)
        comparison_count = values['support']
        cleanedList = values['max-G_test']
        #cleanedList = [return_gtest(i) for i in x if str(i) != 'nan']
        y[comparison_count].append(cleanedList)
    y = dict(y)
    new_dict = y
#     for k,v in y.items():
#         flatlist = [i for sub in v for i in sub]
#         new_dict[k] = flatlist
    df_gtests_candidates = pd.DataFrame.from_dict(new_dict,orient = 'index').sort_index().T
    fig, ax = plt.subplots(figsize=(50,10))
    ax = sns.boxplot(data=df_gtests_candidates,palette=['royalblue'])
    plt.ylabel('G-test score')
    plt.xlabel('Number of comparisons')
    plt.savefig(output_dir,bbox_inches='tight')
//  [python]
def run_gtest(df,columns,output_dir):
    output_dir = output_dir + '/gtest-comparison.pdf'
    y = defaultdict(list)
    for k,values in df.iterrows():
        x = [values[i] for i in columns]
#         print('XXX',x)
        comparison_count = values['support']
        cleanedList = values['max-G_test']
        #cleanedList = [return_gtest(i) for i in x if str(i) != 'nan']
        y[comparison_count].append(cleanedList)
    y = dict(y)
    new_dict = y
#     for k,v in y.items():
#         flatlist = [i for sub in v for i in sub]
#         new_dict[k] = flatlist
    df_gtests_candidates = pd.DataFrame.from_dict(new_dict,orient = 'index').sort_index().T
    fig, ax = plt.subplots(figsize=(50,10))
    ax = sns.catplot(data=df_gtests_candidates,palette=['royalblue'])
    plt.ylabel('G-test score')
    plt.xlabel('Number of comparisons')
    plt.savefig(output_dir,bbox_inches='tight')
//  [python]
def plot_grouped_boxplot(self):

        toplot = self.results.stack()
        toplot.name = 'timing'
        toplot = toplot.reset_index()

        g = sns.catplot(
            x="file", y="timing", hue="cli", row="timing_type",
            data=toplot, kind="box", height=4, aspect=2,
            sharex=True, sharey=False,
        )
        g.fig.savefig(self.base_dir_path / 'catplot.png')
        self._grouped_boxplot = g.fig
//  [python]
def runtime_plots(benchmark_list, dname_out):
    # gather benchmark information
    tmp = []
    for fname in benchmark_list:
        parts = str(fname).split("/")
        if len(parts) == 7:
            _, _, params, method, _, replicate, _ = parts
        elif len(parts) == 8:  # for multi workflow
            _, _, _, params, method, _, replicate, _ = parts

        df_tmp = pd.read_csv(fname, sep="\t")
        df_tmp["method"] = method
        df_tmp["params"] = params
        df_tmp["replicate"] = replicate

        tmp.append(df_tmp)
    df_bench = pd.concat(tmp).replace("-", pd.NA)

    # plot
    df_long = (
        pd.melt(df_bench, id_vars=["method", "params", "replicate"])
        .assign(params=lambda x: x["params"].str.replace("_", "\n"))
        .query("variable == 's'")
    )
    df_long.to_csv(dname_out / "runtime.csv")

    g = sns.boxplot(
        data=df_long,
        x="params",
        y="value",
        hue="method",
    )

    g.yaxis.set_major_formatter(duration_fmt)

    plt.savefig(dname_out / "runtime_boxplot.pdf")
//  [python]
def runtime_plots(benchmark_list, dname_out):
    # gather benchmark information
    tmp = []
    for fname in benchmark_list:
        parts = str(fname).split("/")
        if len(parts) == 7:
            _, _, params, method, _, replicate, _ = parts
        elif len(parts) == 8:  # for multi workflow
            _, _, _, params, method, _, replicate, _ = parts

        df_tmp = pd.read_csv(fname, sep="\t")
        df_tmp["method"] = method
        df_tmp["params"] = params
        df_tmp["replicate"] = replicate

        tmp.append(df_tmp)
    df_bench = pd.concat(tmp).replace("-", pd.NA)

    # plot
    df_long = (
        pd.melt(df_bench, id_vars=["method", "params", "replicate"])
        .assign(params=lambda x: x["params"].str.replace("_", "\n"))
        .query("variable == 's'")
    )
    df_long.to_csv(dname_out / "runtime.csv")

    g = sns.catplot(
        data=df_long,
        x="params",
        y="value",
        hue="method",
        col="variable",
        kind="box",
    )

    for ax in g.axes.flat:
        ax.yaxis.set_major_formatter(duration_fmt)

    g.savefig(dname_out / "runtime_boxplot.pdf")
//  [python]
plotstyle="ggplot"
# sns.set_style(f"{plotstyle}")
plt.style.use(f"{plotstyle}")

COMPARE = ['2 UAVs.p','3 UAVs.p','4 UAVs.p', '5 UAVs.p', '6 UAVs.p']

if __name__ == "__main__":

    dataFrameList = []
    for pickle_in in COMPARE:

        file = open(pickle_in, "rb")
        dataFrameList.append(pickle.load(file))
        file.close()

    dataFrame = pd.concat(dataFrameList)

    # plt.figure(num=None, figsize=(6, 4), dpi=80)
    fig, ax = plt.subplots(figsize=(6,4))

    # https://stackoverflow.com/questions/22591174/pandas-multiple-conditions-while-indexing-data-frame-unexpected-behavior
    dataFrame = dataFrame.drop(dataFrame.index[ (dataFrame['Swarm Size']=="6 UAVs") & (dataFrame['Objective Function']>82) ])

    g = sns.violinplot(x="Swarm Size", y="Objective Function", inner=None, data=dataFrame[dataFrame['Time Steps']>150])
    sns.swarmplot(x="Swarm Size", y="Objective Function", color="k", size=0.4, data=dataFrame, ax=ax)

    # plt.show()
    plt.gcf().set_size_inches((6,4))
    plt.tight_layout()
    plt.savefig(f"Compare.png")
//  [python]
plotstyle="ggplot"
# sns.set_style(f"{plotstyle}")
plt.style.use(f"{plotstyle}")

COMPARE = ['2 UAVs.p','3 UAVs.p','4 UAVs.p', '5 UAVs.p', '6 UAVs.p']

if __name__ == "__main__":

    dataFrameList = []
    for pickle_in in COMPARE:

        file = open(pickle_in, "rb")
        dataFrameList.append(pickle.load(file))
        file.close()

    dataFrame = pd.concat(dataFrameList)

    # plt.figure(num=None, figsize=(6, 4), dpi=80)
    fig, ax = plt.subplots(figsize=(6,4))

    # https://stackoverflow.com/questions/22591174/pandas-multiple-conditions-while-indexing-data-frame-unexpected-behavior
    dataFrame = dataFrame.drop(dataFrame.index[ (dataFrame['Swarm Size']=="6 UAVs") & (dataFrame['Objective Function']>82) ])

    g = sns.catplot(x="Swarm Size", y="Objective Function",kind="violin",inner=None, data=dataFrame[dataFrame['Time Steps']>150])
    sns.swarmplot(x="Swarm Size", y="Objective Function", color="k", size=0.4, data=dataFrame, ax=g.ax)

    # plt.show()
    plt.gcf().set_size_inches((6,4))
    plt.tight_layout()
    plt.savefig(f"Compare.png")
//  [python]
def visFutureCat(self):
        future_rate = 3
        demand_supply = self.demand.copy()
        demand_supply_results = demand_supply[demand_supply['adoption rate']>future_rate]

        peakridge = demand_supply_results.copy()
        peakridge['shifting'] = ' '
        peakridge['day'] = 'Grid Peak Hours'
        peakridge['peak value'] = peakridge['week_peak_before']/1000
        peakridges = peakridge.copy()

        peakridge['shifting'] = '   '
        peakridge['day'] = 'Grid Peak Hours'
        peakridge['peak value'] = peakridge['week_peak_after']/1000
        peakridges = pd.concat([peakridges,peakridge.copy()])

        offpeakridge = demand_supply_results.copy()
        offpeakridge['shifting'] = ' '
        offpeakridge['day'] = 'Grid Off-Peak Hours'
        offpeakridge['peak value'] = offpeakridge['week_offpeak_before']/1000
        offpeakridges = offpeakridge.copy()

        offpeakridge['shifting'] = '   '
        offpeakridge['day'] = 'Grid Off-Peak Hours'
        offpeakridge['peak value'] = offpeakridge['week_offpeak_after']/1000
        offpeakridges = pd.concat([offpeakridges,offpeakridge.copy()])

        g = sns.factorplot(
            data=peakridges, x="adoption rate", y="peak value", hue="shifting",
            capsize=.2, palette="YlOrRd_d", errorbar=None,
            kind="point", size=3, aspect=1.3, legend=False
        )
        g.set_xlabels('               ', fontsize=fsize)
        g.set_ylabels('               ', fontsize=fsize)
        g.set_titles('               ', fontsize=fsize)
        plt.xticks(fontsize=fsize)
        plt.yticks(fontsize=fsize)
        plt.legend(frameon=False, fontsize=fsize, loc=[0.1,0.7]).set_title('')
        plt.ylim([0,25])
        plt.savefig(os.path.join(self.figure_folder_name,'fig4_cat_peak.pdf'),format='pdf',dpi=300,transparent=True,bbox_inches='tight')
        plt.show()

        g = sns.factorplot(
            data=offpeakridges, x="adoption rate", y="peak value", hue="shifting", 
            capsize=.2, palette="YlGnBu_d", errorbar=None,
            kind="point", size=3, aspect=1.3, legend=False
        )
        g.set_xlabels('               ', fontsize=fsize)
        g.set_ylabels('               ', fontsize=fsize)
        g.set_titles('               ', fontsize=fsize)
        plt.xticks(fontsize=12)
        plt.yticks(fontsize=12)
        plt.legend(frameon=False, fontsize=fsize, loc=[0.1,0.7]).set_title('')
        plt.ylim([0,25])
        plt.savefig(os.path.join(self.figure_folder_name,'fig4_cat_offpeak.pdf'),format='pdf',dpi=300,transparent=True,bbox_inches='tight')
        plt.show()
//  [python]
def visFutureCat(self):
        future_rate = 3
        demand_supply = self.demand.copy()
        demand_supply_results = demand_supply[demand_supply['adoption rate']>future_rate]

        peakridge = demand_supply_results.copy()
        peakridge['shifting'] = ' '
        peakridge['day'] = 'Grid Peak Hours'
        peakridge['peak value'] = peakridge['week_peak_before']/1000
        peakridges = peakridge.copy()

        peakridge['shifting'] = '   '
        peakridge['day'] = 'Grid Peak Hours'
        peakridge['peak value'] = peakridge['week_peak_after']/1000
        peakridges = pd.concat([peakridges,peakridge.copy()])

        offpeakridge = demand_supply_results.copy()
        offpeakridge['shifting'] = ' '
        offpeakridge['day'] = 'Grid Off-Peak Hours'
        offpeakridge['peak value'] = offpeakridge['week_offpeak_before']/1000
        offpeakridges = offpeakridge.copy()

        offpeakridge['shifting'] = '   '
        offpeakridge['day'] = 'Grid Off-Peak Hours'
        offpeakridge['peak value'] = offpeakridge['week_offpeak_after']/1000
        offpeakridges = pd.concat([offpeakridges,offpeakridge.copy()])

        g = sns.catplot(
            data=peakridges, x="adoption rate", y="peak value", hue="shifting",
            capsize=.2, palette="YlOrRd_d", errorbar=None,
            kind="point", height=3, aspect=1.3, legend=False
        )
        g.set_xlabels('               ', fontsize=fsize)
        g.set_ylabels('               ', fontsize=fsize)
        g.set_titles('               ', fontsize=fsize)
        plt.xticks(fontsize=fsize)
        plt.yticks(fontsize=fsize)
        plt.legend(frameon=False, fontsize=fsize, loc=[0.1,0.7]).set_title('')
        plt.ylim([0,25])
        plt.savefig(os.path.join(self.figure_folder_name,'fig4_cat_peak.pdf'),format='pdf',dpi=300,transparent=True,bbox_inches='tight')
        plt.show()

        g = sns.catplot(
            data=offpeakridges, x="adoption rate", y="peak value", hue="shifting", 
            capsize=.2, palette="YlGnBu_d", errorbar=None,
            kind="point", height=3, aspect=1.3, legend=False
        )
        g.set_xlabels('               ', fontsize=fsize)
        g.set_ylabels('               ', fontsize=fsize)
        g.set_titles('               ', fontsize=fsize)
        plt.xticks(fontsize=12)
        plt.yticks(fontsize=12)
        plt.legend(frameon=False, fontsize=fsize, loc=[0.1,0.7]).set_title('')
        plt.ylim([0,25])
        plt.savefig(os.path.join(self.figure_folder_name,'fig4_cat_offpeak.pdf'),format='pdf',dpi=300,transparent=True,bbox_inches='tight')
        plt.show()
//  [python]
def plot(all_exps):
    """ Make a scatterplot of weighting schemes vs returns """
    # Reduce the experiment logs values across **time**
    frame = log_processor.to_data_frame(all_exps, reduce_fn=log_processor.reduce_last)
    # Take the mean of weighting schemes across **experiments**
    frame = log_processor.reduce_mean_keys(frame, col_keys=('weighting_scheme', 'layers'))
     
    # Rename axes to more readable names on the plot
    #frame = log_processor.rename_partitions(frame, plot_utils.WEIGHT_NAME_MAP, col_key="weighting_scheme")
    #frame = log_processor.rename_values(frame, plot_utils.VALUE_NAME_MAP)

    sns.set(style="whitegrid")
    #f, ax = plt.subplots(figsize=(6, 15))
    arch_types = ['tabular', '(256, 256)', '(64, 64)', '(16, 16)', '(4, 4)']#frame['layers'].unique()
    weight_order = ['uniform', 'robust_prioritized', 'buffer_infinite', 'buffer10', 'random', 'pi', 'pi*']

    g = sns.factorplot(x="weighting_scheme", y="returns_normalized_50_step_mean", hue="layers", data=frame,
                    hue_order=arch_types,
                    order=weight_order,
                    size=6, kind="bar", palette="muted", legend_out=False)
    g.despine(left=True)

    #colors = sns.mpl_palette("Blues", n_colors=len(arch_types))
    #for color, arch_type in zip(colors, arch_types):
    #    sns.barplot(x="returns_normalized_50_step_mean", y="weighting_scheme", data=frame[frame['layers']==arch_type],
    #                label=arch_type, color=color)

    #ax.legend(ncol=2, loc="lower right", frameon=True)
    #ax.set(xlim=(0, 24), ylabel="",
    #    xlabel="Automobile collisions per billion miles")
    sns.despine(left=True, bottom=True)


    plt.show()
//  [python]
def plot(all_exps):
    """ Make a scatterplot of weighting schemes vs returns """
    # Reduce the experiment logs values across **time**
    frame = log_processor.to_data_frame(all_exps, reduce_fn=log_processor.reduce_last)
    # Take the mean of weighting schemes across **experiments**
    frame = log_processor.reduce_mean_keys(frame, col_keys=('weighting_scheme', 'layers'))
     
    # Rename axes to more readable names on the plot
    #frame = log_processor.rename_partitions(frame, plot_utils.WEIGHT_NAME_MAP, col_key="weighting_scheme")
    #frame = log_processor.rename_values(frame, plot_utils.VALUE_NAME_MAP)

    sns.set(style="whitegrid")
    #f, ax = plt.subplots(figsize=(6, 15))
    arch_types = ['tabular', '(256, 256)', '(64, 64)', '(16, 16)', '(4, 4)']#frame['layers'].unique()
    weight_order = ['uniform', 'robust_prioritized', 'buffer_infinite', 'buffer10', 'random', 'pi', 'pi*']

    g = sns.catplot(x="weighting_scheme", y="returns_normalized_50_step_mean", hue="layers", data=frame,
                    hue_order=arch_types,
                    order=weight_order,
                    height=6, kind="bar", palette="muted", legend_out=False)
    g.despine(left=True)

    #colors = sns.mpl_palette("Blues", n_colors=len(arch_types))
    #for color, arch_type in zip(colors, arch_types):
    #    sns.barplot(x="returns_normalized_50_step_mean", y="weighting_scheme", data=frame[frame['layers']==arch_type],
    #                label=arch_type, color=color)

    #ax.legend(ncol=2, loc="lower right", frameon=True)
    #ax.set(xlim=(0, 24), ylabel="",
    #    xlabel="Automobile collisions per billion miles")
    sns.despine(left=True, bottom=True)


    plt.show()
//  [python]
def display_cat_violin(self, metrics_df, metric_key, path_save=None, save_name=None, num_algo=3, save_mode=1):
        """Display predict metric violin by channel.
        Args:
            metrics_df (pd.DataFrame): DataFrame of the metrics.
            metric_key (str): keyword name of the metric.
            path_save (str): path where to save the figures.
            save_name (str, optional): front keywords of the saved files. Defaults to None.
            num_algo (int, optional): number of the algorithms. Defaults to 3.
            save_mode (int, optional): mode for save files. Defaults to 1.
        """
        config_dict = {}
        if metric_key in ('mse',):
            config_dict.update({'cut': 0})

        if save_mode == 1:
            fig, axes = plt.subplots(1, num_algo+1, sharey='all', figsize=(40, 15), dpi=1000.0)
        for i_algo in range(0, num_algo + 1):
            metric_i_algo = metrics_df[metrics_df.algorithm_type == i_algo]
            metric_i_algo = metric_i_algo.loc[:, ['model_type', 'target_number', 'metric']]
            metric_i_algo = metric_i_algo.explode('metric')
            metric_i_algo['metric'] = metric_i_algo['metric'].astype('float32')
            if save_mode == 0 and path_save:
                cat = sns.violinplot(data=metric_i_algo,
                                  x='model_type', y='metric', hue='target_number',
                                  scale='count', **config_dict
                                  )
                cat.set_xlabels('Model')
                cat.set_ylabels(f'{metric_key.upper()}')
                plt.savefig(os.path.join(path_save, f'{save_name}_algo_{i_algo}_cat_violin.svg'))
                plt.close()
            if save_mode == 1:
                axes_i = sns.violinplot(ax=axes[i_algo - 1], data=metric_i_algo,
                                        x='model_type', y='metric', hue='target_number',
                                        scale='count', **config_dict
                                        )
                axes_i.set_xlabel('Model')
                axes_i.set_ylabel(f'{metric_key.upper()}')
                axes_i.set_title(f'Algorithm {i_algo}')

        if save_mode == 1 and path_save:
            plt.savefig(os.path.join(path_save, f'{save_name}_cat_violin.svg'))
//  [python]
def display_cat_violin(self, metrics_df, metric_key, path_save=None, save_name=None, num_algo=3, save_mode=1):
        """Display predict metric violin by channel.
        Args:
            metrics_df (pd.DataFrame): DataFrame of the metrics.
            metric_key (str): keyword name of the metric.
            path_save (str): path where to save the figures.
            save_name (str, optional): front keywords of the saved files. Defaults to None.
            num_algo (int, optional): number of the algorithms. Defaults to 3.
            save_mode (int, optional): mode for save files. Defaults to 1.
        """
        config_dict = {}
        if metric_key in ('mse',):
            config_dict.update({'cut': 0})

        if save_mode == 1:
            fig, axes = plt.subplots(1, num_algo+1, sharey='all', figsize=(40, 15), dpi=1000.0)
        for i_algo in range(0, num_algo + 1):
            metric_i_algo = metrics_df[metrics_df.algorithm_type == i_algo]
            metric_i_algo = metric_i_algo.loc[:, ['model_type', 'target_number', 'metric']]
            metric_i_algo = metric_i_algo.explode('metric')
            metric_i_algo['metric'] = metric_i_algo['metric'].astype('float32')
            if save_mode == 0 and path_save:
                cat = sns.catplot(data=metric_i_algo,
                                  x='model_type', y='metric', hue='target_number',
                                  kind='violin', scale='count', **config_dict
                                  )
                cat.set_xlabels('Model')
                cat.set_ylabels(f'{metric_key.upper()}')
                plt.savefig(os.path.join(path_save, f'{save_name}_algo_{i_algo}_cat_violin.svg'))
                plt.close()
            if save_mode == 1:
                axes_i = sns.violinplot(ax=axes[i_algo - 1], data=metric_i_algo,
                                        x='model_type', y='metric', hue='target_number',
                                        scale='count', **config_dict
                                        )
                axes_i.set_xlabel('Model')
                axes_i.set_ylabel(f'{metric_key.upper()}')
                axes_i.set_title(f'Algorithm {i_algo}')

        if save_mode == 1 and path_save:
            plt.savefig(os.path.join(path_save, f'{save_name}_cat_violin.svg'))
//  [python]
def plotting_function2(data):

    data['ISD'] = round(data['ISD'], 3)

    bins = [0, 1, 2, 3, 4, 5]
    data['ISD_binned'] = pd.cut(data['ISD'], bins, labels=["1", "2", "3", "4", "5"])

    plot = sns.factorplot(x='ISD_binned', y='Cost',
        hue="Metric",
        col="Strategy", col_wrap=2,
        kind='bar',
        data=data,
        palette=sns.color_palette("husl", 10),
        sharex=True,
        sharey=True,
        legend="full"
        )

    handles = plot._legend_data.values()
    labels = plot._legend_data.keys()
    plot._legend.remove()
    plot.fig.legend(handles=handles, labels=labels,
        loc='lower center', ncol=6)

    plot.axes[0].set_ylabel('Cost (USD$k km^2)')
    plot.axes[1].set_ylabel('Cost (USD$k km^2)')
    plot.axes[2].set_ylabel('Cost (USD$k km^2)')
    plot.axes[3].set_ylabel('Cost (USD$k km^2)')

    plot.axes[0].set_xlabel('ISD (km)')
    plot.axes[1].set_xlabel('ISD (km)')
    plot.axes[2].set_xlabel('ISD (km)')
    plot.axes[3].set_xlabel('ISD (km)')

    plt.subplots_adjust(hspace=0.2, wspace=0.1, bottom=0.1)

    plot.savefig(DATA_OUTPUT + '/costs_capacity_barplot_isd_density.png', dpi=300)

    return print('completed (capacity-cost) replot (isd)')
//  [python]
def plotting_function2(data):

    data['ISD'] = round(data['ISD'], 3)

    bins = [0, 1, 2, 3, 4, 5]
    data['ISD_binned'] = pd.cut(data['ISD'], bins, labels=["1", "2", "3", "4", "5"])

    plot = sns.catplot(x='ISD_binned', y='Cost',
        hue="Metric",
        col="Strategy", col_wrap=2,
        kind='bar',
        data=data,
        palette=sns.color_palette("husl", 10),
        sharex=True,
        sharey=True,
        legend="full"
        )

    handles = plot._legend_data.values()
    labels = plot._legend_data.keys()
    plot._legend.remove()
    plot.fig.legend(handles=handles, labels=labels,
        loc='lower center', ncol=6)

    plot.axes[0].set_ylabel('Cost (USD$k km^2)')
    plot.axes[1].set_ylabel('Cost (USD$k km^2)')
    plot.axes[2].set_ylabel('Cost (USD$k km^2)')
    plot.axes[3].set_ylabel('Cost (USD$k km^2)')

    plot.axes[0].set_xlabel('ISD (km)')
    plot.axes[1].set_xlabel('ISD (km)')
    plot.axes[2].set_xlabel('ISD (km)')
    plot.axes[3].set_xlabel('ISD (km)')

    plt.subplots_adjust(hspace=0.2, wspace=0.1, bottom=0.1)

    plot.savefig(DATA_OUTPUT + '/costs_capacity_barplot_isd_density.png', dpi=300)

    return print('completed (capacity-cost) replot (isd)')
//  [python]
def gen_plots(data, options):

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

    #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='aug_type', y='result', hue='basetrain', data=linear_data, linestyles="-", ci=None)
    plt.close(1) 
    plt.xlabel("Augmentation Sets")
    plt.ylabel("Accuracy")
    plt.title(options['data_name'].replace("_", " ").title())

    #when you run the program, it shows 2 graphs (sns graph and empty graph)
    #Figure 1 is the empty graph; Figure 2 is the sns graph
    # plt.show()

    #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 gen_plots(data, options):

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

    #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='aug_type', y='result', hue='basetrain', data=linear_data, kind="point",linestyle="-", ci=None)
    plt.close(1) 
    plt.xlabel("Augmentation Sets")
    plt.ylabel("Accuracy")
    plt.title(options['data_name'].replace("_", " ").title())

    #when you run the program, it shows 2 graphs (sns graph and empty graph)
    #Figure 1 is the empty graph; Figure 2 is the sns graph
    # plt.show()

    #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 catplot(self, kind="strip", **catplot_kws) -> sns.FacetGrid:
        """
        A simple seaborn catplot

        Returns:
            _type_: sns.FacetGrid
        """

        ### Handle kwargs
        kws = dict(
            kind=kind,
            data=self.data,
            height=2.5,
            **self.factors_as_dict,
            facet_kws=dict(despine=False),
        )
        kws.update(catplot_kws)

        g = sns.catplot(**kws)
        plt.show()
        return g
//  [python]
def analyze_pcap(rl_algos, tcp_algos, plt_name, runs, data_dir):
    import matplotlib
    matplotlib.use('Agg')
    import matplotlib.pyplot as plt
    import seaborn as sns

    algos = rl_algos + tcp_algos
    host_rtt = {}
    for algo in algos:
        host_rtt[algo] = process_rtt_files(data_dir, runs, algo)
    pcap_df = pd.DataFrame.from_dict(host_rtt, orient='index')
    pcap_df = pd.melt(pcap_df.reset_index(),
                      id_vars='index',
                      var_name="Metric",
                      value_name="Average RTT (ms)")
    pcap_df = pcap_df.rename(columns={'index': 'Algorithm'})
    # Convert to milliseconds
    # pcap_df = pcap_df.div(1e6)
    fig = sns.factorplot(x='Metric',
                      y='Average RTT (ms)',
                      hue="Algorithm",
                      data=pcap_df,
                      kind='bar')
    from itertools import cycle
    hatches = cycle(["/", "-", "+", "x", '-', '+', 'x', 'O', '.'])

    num_locations = len(pcap_df.Metric.unique())
    for i, patch in enumerate(fig.ax.patches):
        # Blue bars first, then green bars
        if i % num_locations == 0:
            hatch = next(hatches)
        patch.set_hatch(hatch)
    plt_name += "_rtt"
    log.info("Saving plot %s", plt_name)
    plt.savefig(plt_name + ".png", bbox_inches='tight', pad_inches=0.05)
    plt.savefig(plt_name + ".pdf", bbox_inches='tight', pad_inches=0.05)
    plt.gcf().clear()