jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
def plot_categorical_and_continous_vars(categorical_var, continuous_var, df):
    sns.factorplot(y=categorical_var, x=continuous_var, data=df) 
    sns.factorplot(x=categorical_var, kind="count", palette="ch:.25", data=df);
    sns.factorplot(x=categorical_var, y=continuous_var, kind="box", data=df);
    sns.factorplot(x=categorical_var, y=continuous_var, kind="violin", bw=.15, cut=0, data=df);
//  [python]
def plot_categorical_and_continous_vars(categorical_var, continuous_var, df):
    sns.catplot(y=categorical_var, x=continuous_var, data=df) 
    sns.catplot(x=categorical_var, kind="count", palette="ch:.25", data=df);
    sns.catplot(x=categorical_var, y=continuous_var, kind="box", data=df);
    sns.catplot(x=categorical_var, y=continuous_var, kind="violin", bw=.15, cut=0, data=df);
//  [python]
def plot_renditions_calibration(df, x="diff", y="rendition", hue="net"):
    set_latex_font()
    dfgb = df[[x, y]].groupby([y]).mean().reset_index()
    order = dfgb.sort_values(x, ascending=False)[y]

    plt.rc("legend", fontsize=11)
    plt.rc("legend", title_fontsize=12)
    plt.rc("legend", handletextpad=0.5)
    plt.rc("legend", columnspacing=1.3)
    plt.rc("legend", borderpad=0.3)
    plt.rc("legend", borderaxespad=0.2)
    plt.rc("legend", handlelength=1.5)
    plt.rc("legend", labelspacing=0.1)
    plt.rc("xtick", labelsize=7)
    plt.rc("ytick", labelsize=11)
    plt.rc("axes", labelsize=12)

    n_renditions = len(np.unique(df[y]))
    np.random.seed(0)
    g = sns.factorplot(data=df, x=x, y=y, hue=hue, order=order, size=3.5)
    fig = g.fig
    ax = fig.axes[0]
    sns.stripplot(
        data=dfgb, x=x, y=y, color="black", ax=ax, jitter=0, order=order, legend=False
    )

    ax.axvline(0, color="darkgray", lw=1, zorder=0)
    xmin, xmax = ax.get_xlim()
    xabs = max(abs(xmin), abs(xmax))
    ax.set_ylim((n_renditions - 0.5, 0.5))

    # Add gray layouts in the background every other rows
    for k in range(1, n_renditions, 2):
        ax.axhspan(k - 0.5, k + 0.5, color=".93", zorder=-1)

    ax.set_xlabel(r"$\bar{C}_{rendition} - \bar{C}_{all}$")
    ax.set_ylabel("Renditions")
    g.legend.set_title("Network")

    return fig
//  [python]
def plot_renditions_calibration(df, x="diff", y="rendition", hue="net"):
    set_latex_font()
    dfgb = df[[x, y]].groupby([y]).mean().reset_index()
    order = dfgb.sort_values(x, ascending=False)[y]

    plt.rc("legend", fontsize=11)
    plt.rc("legend", title_fontsize=12)
    plt.rc("legend", handletextpad=0.5)
    plt.rc("legend", columnspacing=1.3)
    plt.rc("legend", borderpad=0.3)
    plt.rc("legend", borderaxespad=0.2)
    plt.rc("legend", handlelength=1.5)
    plt.rc("legend", labelspacing=0.1)
    plt.rc("xtick", labelsize=7)
    plt.rc("ytick", labelsize=11)
    plt.rc("axes", labelsize=12)

    n_renditions = len(np.unique(df[y]))
    np.random.seed(0)
    g = sns.catplot(data=df, x=x, y=y, hue=hue, order=order, height=3.5)
    fig = g.figure
    ax = fig.axes[0]
    sns.stripplot(
        data=dfgb, x=x, y=y, color="black", ax=ax, jitter=0, order=order, legend=False
    )

    ax.axvline(0, color="darkgray", lw=1, zorder=0)
    xmin, xmax = ax.get_xlim()
    xabs = max(abs(xmin), abs(xmax))
    ax.set_ylim((n_renditions - 0.5, 0.5))

    # Add gray layouts in the background every other rows
    for k in range(1, n_renditions, 2):
        ax.axhspan(k - 0.5, k + 0.5, color=".93", zorder=-1)

    ax.set_xlabel(r"$\bar{C}_{rendition} - \bar{C}_{all}$")
    ax.set_ylabel("Renditions")
    g.legend.set_title("Network")

    return fig
//  [python]
def cmp_sss(files, output, test, **kwargs):
    import pandas as pd
    import seaborn as sns
    import matplotlib.pyplot as plt
    from statannotations.Annotator import Annotator

    df_ls = [pd.read_csv(file, index_col=0) for file in files]
    gns = kwargs.get("groupnames")
    for i, df in enumerate(df_ls):
        df["condition"] = gns[i]

    df = pd.concat(df_ls)
    dft = df.melt(id_vars=["condition"], var_name="splice_site", value_name="score")
    sns.set_theme()
    pairs = [[(i, gn) for gn in gns] for i in df.columns[:-1]]
    fig_type = kwargs.get("figtype", "point")
    fig_kwargs = {"split": True} if fig_type == "strip" else {}
    if all([kwargs["width"], kwargs["height"]]):
        fig_kwargs["height"] = kwargs["height"]
        fig_kwargs["aspect"] = kwargs["width"] / kwargs["height"]
    g = sns.factorplot(
        data=dft, x="splice_site", y="score", 
        hue="condition", kind=fig_type, legend=False, **fig_kwargs
    )
    annotator = Annotator(g.ax, pairs, data=dft, x="splice_site", y="score", hue="condition")
    annotator.configure(test=test, text_format="star", show_test_name=False)
    annotator.apply_test()
    annotator.annotate()
    plt.legend(loc='upper left', bbox_to_anchor=(1.03, 1))
    fig_fmt = kwargs.get("figformat", "auto")
    if fig_fmt == "auto":
        fig_fmt = sniff_fig_fmt(output, fmts=['png', 'pdf', 'tiff', 'jpeg'])

    output = Path(output).with_suffix(f".{fig_fmt}")
    plt.savefig(output, dpi=300, bbox_inches='tight', facecolor="w")
//  [python]
def cmp_sss(files, output, test, **kwargs):
    import pandas as pd
    import seaborn as sns
    import matplotlib.pyplot as plt
    from statannotations.Annotator import Annotator

    df_ls = [pd.read_csv(file, index_col=0) for file in files]
    gns = kwargs.get("groupnames")
    for i, df in enumerate(df_ls):
        df["condition"] = gns[i]

    df = pd.concat(df_ls)
    dft = df.melt(id_vars=["condition"], var_name="splice_site", value_name="score")
    sns.set_theme()
    pairs = [[(i, gn) for gn in gns] for i in df.columns[:-1]]
    fig_type = kwargs.get("figtype", "point")
    fig_kwargs = {"split": True} if fig_type == "strip" else {}
    if all([kwargs["width"], kwargs["height"]]):
        fig_kwargs["height"] = kwargs["height"]
        fig_kwargs["aspect"] = kwargs["width"] / kwargs["height"]
    g = sns.catplot(
        data=dft, x="splice_site", y="score", 
        hue="condition", kind=fig_type, legend=False, **fig_kwargs
    )
    annotator = Annotator(g.ax, pairs, data=dft, x="splice_site", y="score", hue="condition")
    annotator.configure(test=test, text_format="star", show_test_name=False)
    annotator.apply_test()
    annotator.annotate()
    plt.legend(loc='upper left', bbox_to_anchor=(1.03, 1))
    fig_fmt = kwargs.get("figformat", "auto")
    if fig_fmt == "auto":
        fig_fmt = sniff_fig_fmt(output, fmts=['png', 'pdf', 'tiff', 'jpeg'])

    output = Path(output).with_suffix(f".{fig_fmt}")
    plt.savefig(output, dpi=300, bbox_inches='tight', facecolor="w")
//  [python]
def barplot_links(video_df, channel_ids):
    '''Create a barplot with counts on how many video descriptions hae clickable links. Save the plot as image.'''

    # Check if there is 'http' in description and insert result
    video_df['Links in decription'] = video_df['description'].str.contains('http').apply(lambda x: 'Clickable Link' if x else 'No clickable Link')

    channel_ids_string = '_'.join(channel_ids)
    image_name = f'static/images/{channel_ids_string}_barplot_links.png'

    video_df = video_df.groupby(['channel_title', 'Links in decription'])[['video_id']].count().reset_index()
    sns.set(style="whitegrid")
    g = sns.factorplot(x="channel_title",
                    y="video_id",
                    hue="Links in decription",
                    data=video_df,
                    height=6,
                    kind="bar",
                    palette="muted"
    )
    g.despine(left=True)
    g.set_xlabels("Channel Name")
    g.set_ylabels("Video Count")
    # g.set_title('Links in Video Descriptions', fontdict = {'fontsize' : TS})
    plt.savefig(image_name, dpi=100)

    return image_name
//  [python]
def barplot_links(video_df, channel_ids):
    '''Create a barplot with counts on how many video descriptions hae clickable links. Save the plot as image.'''

    # Check if there is 'http' in description and insert result
    video_df['Links in decription'] = video_df['description'].str.contains('http').apply(lambda x: 'Clickable Link' if x else 'No clickable Link')

    channel_ids_string = '_'.join(channel_ids)
    image_name = f'static/images/{channel_ids_string}_barplot_links.png'

    video_df = video_df.groupby(['channel_title', 'Links in decription'])[['video_id']].count().reset_index()
    sns.set(style="whitegrid")
    g = sns.catplot(x="channel_title",
                    y="video_id",
                    hue="Links in decription",
                    data=video_df,
                    height=6,
                    kind="bar",
                    palette="muted"
    )
    g.despine(left=True)
    g.set_xlabels("Channel Name")
    g.set_ylabels("Video Count")
    # g.set_title('Links in Video Descriptions', fontdict = {'fontsize' : TS})
    plt.savefig(image_name, dpi=100)

    return image_name
//  [python]
def plotPerformance(TestDF, TrainDF):
	# Bring in matplotlib
	import matplotlib
	matplotlib.use('Agg')
	import matplotlib.pyplot as plt
	from matplotlib import colors
	matplotlib.style.use('default')
	import seaborn as sns
	from matplotlib.gridspec import GridSpec
	plt.rcParams.update({'font.size': 22})
	sns.set(font_scale=1.25,style="ticks")

	PerfDF = pd.concat([TrainDF,TestDF],axis=0)
	PlotName = "NBL_Input_Feature_Performance_Dist.png"
	g = sns.FacetGrid(PerfDF, col="sample set", hue="feature type", palette="colorblind", height=5, aspect=1)
	g.map(sns.boxplot, "window size", "performance")
	g.add_legend()
	g.set_ylabels('Feature performance ($\mathregular{R^2}$)')
	g.fig.suptitle("Feature performance comparison, Input features vs CNN mapped features\n\n")
	g.fig.subplots_adjust(top=0.85)
	plt.savefig(PlotName)
	plt.clf()
//  [python]
def plotPerformance(TestDF, TrainDF):
	# Bring in matplotlib
	import matplotlib
	matplotlib.use('Agg')
	import matplotlib.pyplot as plt
	from matplotlib import colors
	matplotlib.style.use('default')
	import seaborn as sns
	from matplotlib.gridspec import GridSpec
	plt.rcParams.update({'font.size': 22})
	sns.set(font_scale=1.25,style="ticks")

	PerfDF = pd.concat([TrainDF,TestDF],axis=0)
	PlotName = "NBL_Input_Feature_Performance_Dist.png"
	Boxplot = sns.catplot(x="window size", y="performance", hue="feature type",
			data=PerfDF, col="sample set", kind="box", palette="colorblind", legend_out=True,
			height=5, aspect=1)
	Boxplot.set_ylabels('Feature performance ($\mathregular{R^2}$)')
	Boxplot.fig.suptitle("Feature performance comparison, Input features vs CNN mapped features\n\n")
	Boxplot.fig.subplots_adjust(top=0.85)
	plt.savefig(PlotName)
	plt.clf()
//  [python]
def plot(
    df,
    theoretical,
    figname,
    x,
    y,
    hue,
    legend_title,
    xtitle,
    ytitle,
    palette="Set2",
    hatches=[],
    texts=[],
    logscale=False,
    legend_kwargs={},
):
    g = sns.barplot(
        data=df,
        x=x,
        y=y,
        hue=hue,
        palette=palette,
    )
    fig = plt.gcf()
    fig.set_size_inches(figheight, figheight / golden_ratio)
    for patches, hatch in zip(g.patches, hatches):
        patches.set_hatch(hatch)
    for args, kwargs in texts:
        g.text(*args, **kwargs)
    sns.despine(left=True)
    plt.xlabel(xtitle, fontsize=20)
    plt.ylabel(ytitle, fontsize=20)
    plt.xticks(fontsize=18)
    plt.yticks(fontsize=18)
    if logscale:
        plt.yscale("log")
    # Legend.
    if legend_title is None:
        g.legend_.remove()
    else:
        kwargs = dict(
            title=legend_title,
            bbox_to_anchor=(0.75, 0.5),
            fontsize=16,
        )
        kwargs.update(legend_kwargs)
        g.legend_.set_title(legend_title)
        g.legend_.set_bbox_to_anchor((0.75, 0.5))
        g.legend_.set_fontsize(16)

    # Add a horizontal line.
    for t in theoretical:
        plt.axhline(
            t,
            color="gray",
            linestyle="--",
            label="theoretical",
        )
    filename = figname + ".pdf"
    print(filename)
    plt.savefig(filename, bbox_inches="tight")
//  [python]
def plot(
    df,
    theoretical,
    figname,
    x,
    y,
    hue,
    legend_title,
    xtitle,
    ytitle,
    palette="Set2",
    hatches=[],
    texts=[],
    logscale=False,
    legend_kwargs={},
):
    g = sns.catplot(
        data=df,
        kind="bar",
        x=x,
        y=y,
        hue=hue,
        palette=palette,
        height=figheight,
        aspect=1 / golden_ratio,
    )
    fig = g.figure
    for patches, hatch in zip(g.ax.containers, hatches):
        for patch in patches:
            patch.set_hatch(hatch)
    for args, kwargs in texts:
        g.ax.text(*args, **kwargs)
    g.despine(left=True)
    plt.xlabel(xtitle, fontsize=20)
    plt.ylabel(ytitle, fontsize=20)
    plt.xticks(fontsize=18)
    plt.yticks(fontsize=18)
    if logscale:
        g.set(yscale="log")
    # Legend.
    if g.legend:
        if legend_title is None:
            g.legend.remove()
        else:
            kwargs = dict(
                title=legend_title,
                bbox_to_anchor=(0.75, 0.5),
                fontsize=16,
            )
            kwargs.update(legend_kwargs)
            sns.move_legend(
                g,
                "center left",
                **kwargs,
            )
    # Add a horizontal line.
    for t in theoretical:
        plt.axhline(
            t,
            figure=fig,
            color="gray",
            linestyle="--",
            label="theoretical",
        )
    filename = figname + ".pdf"
    print(filename)
    g.savefig(filename, bbox_inches="tight")
//  [python]
def plot_data(pd_df, experiment_type, out_path='test.png'):
    sns.set_theme(style="whitegrid")
    if experiment_type == "suppression":
        title = "Suppressing knowledge neurons"
    elif experiment_type == "enhancement":
        title = "Enhancing knowledge neurons"
    else:
        raise ValueError
    # Draw a nested barplot by species and sex
    g = sns.factorplot(
        data=pd_df, kind="bar",
        x="relation_name", y="pct_change", hue="related",
        ci="sd", palette="dark", alpha=.6, size=6, aspect=4
    )
    g.despine(left=True)
    g.set_axis_labels("relation name", "Correct probability percentage change")
    g.legend.set_title(title)
    g.savefig(out_path)
//  [python]
def plot_data(pd_df, experiment_type, out_path='test.png'):
    sns.set_theme(style="whitegrid")
    if experiment_type == "suppression":
        title = "Suppressing knowledge neurons"
    elif experiment_type == "enhancement":
        title = "Enhancing knowledge neurons"
    else:
        raise ValueError
    # Draw a nested barplot by species and sex
    g = sns.catplot(
        data=pd_df, kind="bar",
        x="relation_name", y="pct_change", hue="related",
        ci="sd", palette="dark", alpha=.6, height=6, aspect=4
    )
    g.despine(left=True)
    g.set_axis_labels("relation name", "Correct probability percentage change")
    g.legend.set_title(title)
    g.savefig(out_path)
//  [python]
def _plot_full_epochs_decoding_scores(
    contrast_names: list[str],
    scores: list[np.ndarray],
    metric: str,
    kind: Literal["single-subject", "grand-average"] = "single-subject",
):
    """Plot cross-validation results from full-epochs decoding."""
    import matplotlib.pyplot as plt  # nested import to help joblib
    import seaborn as sns

    if metric == "roc_auc":
        metric = "ROC AUC"
    score_label = f"Score ({metric})"

    data = pd.DataFrame(
        {
            "Contrast": np.array(
                [[c] * len(scores[0]) for c in contrast_names]
            ).flatten(),
            score_label: np.hstack(scores),
        }
    )

    if kind == "grand-average":
        # First create a grid of boxplots …
        g = sns.FacetGrid(
            data=data,
            col="Contrast",
            col_wrap=3,
            aspect=0.33,
        )
        g.map(sns.boxplot, score_label)
        # … and now add swarmplots on top to visualize every single data point.
        g.map(sns.swarmplot, score_label, color="black")
        caption = (
            f"Based on N={len(scores[0])} "
            f"subjects. Each dot represents the mean cross-validation score "
            f"for a single subject. The dashed line is expected chance "
            f"performance."
        )
    else:
        # First create a grid of swarmplots to visualize every single
        # cross-validation score.
        g = sns.FacetGrid(
            data=data,
            col="Contrast",
            col_wrap=3,
            aspect=0.33,
        )
        g.map(sns.swarmplot, score_label, color="black")

        # And now add the mean CV score on top.
        def _plot_mean_cv_score(x, **kwargs):
            plt.plot(x.mean(), **kwargs)

        g.map(
            _plot_mean_cv_score,
            score_label,
            marker="+",
            color="red",
            ms=15,
            label="mean score",
            zorder=99,
        )
        caption = (
            "Each black dot represents the single cross-validation score. "
            f"The red cross is the mean of all {len(scores[0])} "
            "cross-validation scores. "
            "The dashed line is expected chance performance."
        )
        plt.xlim([-0.1, 0.1])

    g.map(plt.axhline, y=0.5, ls="--", lw=0.5, color="black", zorder=99)
    g.set_titles("{col_name}")  # use this argument literally!
    g.set_xlabels("")

    fig = g.fig
    return fig, caption, data
//  [python]
def _plot_full_epochs_decoding_scores(
    contrast_names: list[str],
    scores: list[np.ndarray],
    metric: str,
    kind: Literal["single-subject", "grand-average"] = "single-subject",
):
    """Plot cross-validation results from full-epochs decoding."""
    import matplotlib.pyplot as plt  # nested import to help joblib
    import seaborn as sns

    if metric == "roc_auc":
        metric = "ROC AUC"
    score_label = f"Score ({metric})"

    data = pd.DataFrame(
        {
            "Contrast": np.array(
                [[c] * len(scores[0]) for c in contrast_names]
            ).flatten(),
            score_label: np.hstack(scores),
        }
    )

    if kind == "grand-average":
        # First create a grid of boxplots …
        g = sns.catplot(
            data=data,
            y=score_label,
            kind="box",
            col="Contrast",
            col_wrap=3,
            aspect=0.33,
        )
        # … and now add swarmplots on top to visualize every single data point.
        g.map_dataframe(sns.swarmplot, y=score_label, color="black")
        caption = (
            f"Based on N={len(scores[0])} "
            f"subjects. Each dot represents the mean cross-validation score "
            f"for a single subject. The dashed line is expected chance "
            f"performance."
        )
    else:
        # First create a grid of swarmplots to visualize every single
        # cross-validation score.
        g = sns.catplot(
            data=data,
            y=score_label,
            kind="swarm",
            col="Contrast",
            col_wrap=3,
            aspect=0.33,
            color="black",
        )

        # And now add the mean CV score on top.
        def _plot_mean_cv_score(x, **kwargs):
            plt.plot(x.mean(), **kwargs)

        g.map(
            _plot_mean_cv_score,
            score_label,
            marker="+",
            color="red",
            ms=15,
            label="mean score",
            zorder=99,
        )
        caption = (
            "Each black dot represents the single cross-validation score. "
            f"The red cross is the mean of all {len(scores[0])} "
            "cross-validation scores. "
            "The dashed line is expected chance performance."
        )
        plt.xlim([-0.1, 0.1])

    g.map(plt.axhline, y=0.5, ls="--", lw=0.5, color="black", zorder=99)
    g.set_titles("{col_name}")  # use this argument literally!
    g.set_xlabels("")

    fig = g.fig
    return fig, caption, data
//  [python]
def plot(cls, benchmark_data):
        rows = cls.get_data_rows(benchmark_data)
        metadata = rows.query(TotalScoreParts.query).name.str.extract(
            r"(?x) \[ (?P<_device>\w*) - (?P<score_pass> \w*)-(?P<component> \w*)\]",
            expand=True,
        )
        data = pandas.concat([rows, metadata], axis=1)

        if len(data.benchmark_run.unique()) > 1:
            data["score_pass"] = data.score_pass.str.cat(data.benchmark_run, sep=":")

        g = seaborn.factorplot(
            data=data[~data.component.str.startswith("total")],
            x="component",
            y="walltime",
            hue="score_pass",
            hue_order=sorted(data["score_pass"].unique(), reverse=True),
            row="torch_device",
            kind="box",
            sharey=False,
            aspect=2,
        )
        for a in g.axes.ravel():
            a.set_ylim(0, None)
        g.set_titles("end_to_end components: {row_var}={row_name}")
//  [python]
def plot(cls, benchmark_data):
        rows = cls.get_data_rows(benchmark_data)
        metadata = rows.query(TotalScoreParts.query).name.str.extract(
            r"(?x) \[ (?P<_device>\w*) - (?P<score_pass> \w*)-(?P<component> \w*)\]",
            expand=True,
        )
        data = pandas.concat([rows, metadata], axis=1)

        if len(data.benchmark_run.unique()) > 1:
            data["score_pass"] = data.score_pass.str.cat(data.benchmark_run, sep=":")

        g = seaborn.catplot(
            data=data[~data.component.str.startswith("total")],
            x="component",
            y="walltime",
            hue="score_pass",
            hue_order=sorted(data["score_pass"].unique(), reverse=True),
            row="torch_device",
            kind="box",
            sharey=False,
            aspect=2,
        )
        for a in g.axes.ravel():
            a.set_ylim(0, None)
        g.set_titles("end_to_end components: {row_var}={row_name}")
//  [python]
def plot_score_of_models(self, models: list, score_name: Union[str,dict], target: str, CVs: list=['test'], save_file=None):
        """Makes bar plots of all given scores of all models. `score_name` can be either a string or a dictionary where the key is the score_name in the csv file and the value is the name in the plot.
        """
        # Allow to override plotted name of score by passing a dict.
        score_name, plot_score_name = disassemble_dict(score_name)
        all_scores = All_scores(self.all_scores_file)
        
        data = []
        for model, CV in product(models, CVs):
            scores = all_scores.get_scores(target, score_name, model, CV)
            for score in scores:
                data.append(
                    {'model': model, 
                     score_name: score,
                     'CV': CV,
                     'target': target
                     })
        data = pd.DataFrame(data)
        
        plt.figure()
        hue = 'CV' if len(CVs) > 1 else None
        sns.barplot(data=data, x='model', y=score_name, hue=hue)
        plt.ylabel(plot_score_name)
        plt.legend(loc='best')
        plt.tight_layout()
        if save_file == None:
            save_file = f'scores_{target}_{score_name}_{"+".join(models)}_{"+".join(CVs)}.png'
        filename = os.path.join(self.analysis_dir, 'scores', save_file)
        self.savefig(filename, dpi=300)
        plt.show()
        plt.clf()
        return
//  [python]
def plot_score_of_models(self, models: list, score_name: Union[str,dict], target: str, CVs: list=['test'], save_file=None):
        """Makes bar plots of all given scores of all models. `score_name` can be either a string or a dictionary where the key is the score_name in the csv file and the value is the name in the plot.
        """
        # Allow to override plotted name of score by passing a dict.
        score_name, plot_score_name = disassemble_dict(score_name)
        all_scores = All_scores(self.all_scores_file)
        
        data = []
        for model, CV in product(models, CVs):
            scores = all_scores.get_scores(target, score_name, model, CV)
            for score in scores:
                data.append(
                    {'model': model, 
                     score_name: score,
                     'CV': CV,
                     'target': target
                     })
        data = pd.DataFrame(data)
        
        plt.figure()
        hue = 'CV' if len(CVs) > 1 else None
        sns.catplot(data=data, x='model', y=score_name, hue=hue, kind='bar', legend=False)
        plt.ylabel(plot_score_name)
        plt.legend(loc='best')
        plt.tight_layout()
        if save_file == None:
            save_file = f'scores_{target}_{score_name}_{"+".join(models)}_{"+".join(CVs)}.png'
        filename = os.path.join(self.analysis_dir, 'scores', save_file)
        self.savefig(filename, dpi=300)
        plt.show()
        plt.clf()
        return
//  [python]
def plot_entropy():
    plt.figure()
    g = sns.boxplot(
        x="eval_data",
        y="prob_entropy",
        hue="is_correct",
        data=dfs_csvs
    )
    g.set_xticklabels(rotation=40)
    g.despine(left=True)
    g.set_title("Average entropy",size=25)
    g.set_ylabel("Average entropy", fontsize=25)
    g.set_xlabel("Dataset", fontsize=25)
    _, xlabels = plt.xticks()
    g.set_xticklabels(xlabels, size=20)
    g.legend(fontsize="xx-large")
    plt.savefig("entropy_plot.png", dpi=300, bbox_inches="tight")
//  [python]
def plot_entropy():
    plt.figure()
    g = sns.catplot(
        x="eval_data",
        y="prob_entropy",
        hue="is_correct",
        col="model_name",
        kind="box",
        col_wrap=3,
        data=dfs_csvs,
        legend=False,
        sym="",
    )
    g.set_xticklabels(rotation=40)
    g.despine(left=True)
    g.set_titles(row_template="{row_name}", col_template="{col_name}", size=25)
    g.set_ylabels("Average entropy", fontsize=25)
    g.set_xlabels("Dataset", fontsize=25)
    _, xlabels = plt.xticks()
    g.set_xticklabels(xlabels, size=20)
    g.add_legend(fontsize="xx-large")
    plt.savefig("entropy_plot.png", dpi=300, bbox_inches="tight")
//  [python]
def visualize_avearage_causal_effects(folder: str, file_name: str = "intervention.csv") -> None:
    """
    Visualize Average Causal Effects.

    References:
        [1] https://seaborn.pydata.org/tutorial/color_palettes.html

    Args:
        folder (str): The folder name where the experimental file exists.
        file_name (str): The experimental file name.
    """
    import matplotlib.pyplot as plt
    import pandas as pd
    import seaborn as sns

    file_name = os.path.join(folder, file_name)
    data = pd.read_csv(file_name, "\t")
    data = data[data["Level"] == "Token"]
    data.loc[data.Augmentation == 0, "Augmentation"] = "No"
    data.loc[data.Augmentation == 1, "Augmentation"] = "Yes"
    sns.factorplot(
        x="N", y="RI", hue="Augmentation", kind="bar", col="Dataset", row="Model",
        palette="Paired", edgecolor="w", linewidth=0.3, aspect = 0.7, data=data
    )
    plt.show()
//  [python]
def visualize_avearage_causal_effects(folder: str, file_name: str = "intervention.csv") -> None:
    """
    Visualize Average Causal Effects.

    References:
        [1] https://seaborn.pydata.org/tutorial/color_palettes.html

    Args:
        folder (str): The folder name where the experimental file exists.
        file_name (str): The experimental file name.
    """
    import matplotlib.pyplot as plt
    import pandas as pd
    import seaborn as sns

    file_name = os.path.join(folder, file_name)
    data = pd.read_csv(file_name, "\t")
    data = data[data["Level"] == "Token"]
    data.loc[data.Augmentation == 0, "Augmentation"] = "No"
    data.loc[data.Augmentation == 1, "Augmentation"] = "Yes"
    sns.catplot(
        x="N", y="RI", hue="Augmentation", kind="bar", col="Dataset", row="Model",
        palette="Paired", edgecolor="w", linewidth=0.3, aspect = 0.7, data=data
    )
    plt.show()
//  [python]
seaborn.set(font_scale=1.2)
seaborn.set_style("darkgrid")
results_df["Element"] = results_df["Space"] + " " + results_df["Degree"]
elements = sorted(set(results_df["Element"]))
for element in elements:
    df_e = results_df[results_df["Element"] == element]
    g = seaborn.factorplot(x="Options", y="Time", kind="bar", data=df_e, col="Element")
    g.fig.set_size_inches(16, 4)
//  [python]
seaborn.set(font_scale=1.2)
seaborn.set_style("darkgrid")
results_df["Element"] = results_df["Space"] + " " + results_df["Degree"]
elements = sorted(set(results_df["Element"]))
for element in elements:
    df_e = results_df[results_df["Element"] == element]
    g = seaborn.catplot(x="Options", y="Time", kind="bar", data=df_e, col="Element")
    g.fig.set_size_inches(16, 4)
//  [python]
def plot_domain_score_of_model(self, domain_col: str, models: list, score_name: Union[str,dict], target: str, CVs: list=['test'], save_file=None, domain_order=None, rotate_xlabels=None, yscale: str='linear', ylim: tuple=None):
        """Makes a barplot of the domain scores of some models.
        """
        # Allow to override plotted name of score by passing a dict.
        score_name, plot_score_name = disassemble_dict(score_name)
        # Get domain data.
        domain_statistics_file = os.path.join(self.run_dir, 'Domain_statistics.csv')
        domain_stats = Domain_statistics(domain_statistics_file, domain_col)
        domains = domain_stats.all_domains
        # Build up df.
        data = []
        for model, CV, domain in product(models, CVs, domains):
            model, plot_model_name = disassemble_dict(model)
            score = domain_stats.get_score(model, domain, score_name, target, CV)
            data.append({
                        'model': plot_model_name,
                        'group': domain,
                        'target': target,
                        'CV': CV,
                        plot_score_name: score
                })
        data = pd.DataFrame(data)
        plot_models = list(data['model'].unique())
        # Plot.
        plt.figure()
        hue = 'group' if len(domains) > 1 else None
        if domain_order == None:
            domain_order = domains
        sns.barplot(data=data, x='model', y=plot_score_name, hue=hue, order=plot_models, hue_order=domain_order)
        # Scale
        plt.yscale(yscale)
        ax = plt.gca()
        ax.yaxis.set_major_formatter(ScalarFormatter())
        plt.ylim(ylim)
        plt.legend(loc='best')
        if rotate_xlabels != None:
            ax.set_xticklabels(rotation=rotate_xlabels, ha="right")
        plt.tight_layout()
        if save_file == None:
            save_file = f'domain_scores_{target}_{score_name}_{"+".join(plot_models)}_{"+".join(CVs)}.png'
        filename = os.path.join(self.analysis_dir, 'domain_scores', save_file)
        self.savefig(filename, dpi=300)
        plt.show()
        plt.clf()
        return
//  [python]
def plot_domain_score_of_model(self, domain_col: str, models: list, score_name: Union[str,dict], target: str, CVs: list=['test'], save_file=None, domain_order=None, rotate_xlabels=None, yscale: str='linear', ylim: tuple=None):
        """Makes a barplot of the domain scores of some models.
        """
        # Allow to override plotted name of score by passing a dict.
        score_name, plot_score_name = disassemble_dict(score_name)
        # Get domain data.
        domain_statistics_file = os.path.join(self.run_dir, 'Domain_statistics.csv')
        domain_stats = Domain_statistics(domain_statistics_file, domain_col)
        domains = domain_stats.all_domains
        # Build up df.
        data = []
        for model, CV, domain in product(models, CVs, domains):
            model, plot_model_name = disassemble_dict(model)
            score = domain_stats.get_score(model, domain, score_name, target, CV)
            data.append({
                        'model': plot_model_name,
                        'group': domain,
                        'target': target,
                        'CV': CV,
                        plot_score_name: score
                })
        data = pd.DataFrame(data)
        plot_models = list(data['model'].unique())
        # Plot.
        plt.figure()
        hue = 'group' if len(domains) > 1 else None
        if domain_order == None:
            domain_order = domains
        sns.catplot(data=data, x='model', y=plot_score_name, hue=hue, hue_order=domain_order, kind='bar', legend=False)
        # Scale
        plt.yscale(yscale)
        ax = plt.gca()
        ax.yaxis.set_major_formatter(ScalarFormatter())
        plt.ylim(ylim)
        plt.legend(loc='best')
        if rotate_xlabels != None:
            ax.set_xticklabels(rotation=rotate_xlabels, ha="right")
        plt.tight_layout()
        if save_file == None:
            save_file = f'domain_scores_{target}_{score_name}_{"+".join(plot_models)}_{"+".join(CVs)}.png'
        filename = os.path.join(self.analysis_dir, 'domain_scores', save_file)
        self.savefig(filename, dpi=300)
        plt.show()
        plt.clf()
        return
//  [python]
def format_time_results(df_all_epochs, unique_run_id):
    time_delta = df_all_epochs.groupby(unique_run_id)["time"].diff() * 60
    time_delta = time_delta[
        time_delta > 0
    ]  # Remove negative values coming from preemption
    total_time = time_delta.sum().item()
    print("Total compute time : " + str(total_time))
    time_result = time_delta.groupby(["dataset", "method", "#HP", "Groups"]).median()
    average = (
        time_result.groupby(["method", "#HP", "Groups"]).mean().to_frame("Average")
    )
    time_result = time_result.unstack("dataset").sort_index(level="Groups")
    time_result = time_result.join(average).apply(lambda x: x.map("{:.2f}".format))
    print(time_result)
    time_result.to_latex(
        "tables/result_time_h.tex", escape=False, multirow=True, multicolumn=True
    )

    sns.set(style="whitegrid", context="talk")
    g = sns.factorplot(
        data=time_delta.to_frame("time").reset_index(),
        x="method",
        y="time",
        col="dataset",
        kind="box",
        sharex=True,
        sharey=False,
        size=6,
        col_wrap=2,
    )
    for ax in g.fig.axes:
        ax.set_yscale("log")
        ax.tick_params(axis="x", labelrotation=45)
    g.set_axis_labels("Method", "Time per epoch in minutes")
    g.set_titles(col_template="{col_name}")
    g.tight_layout()
    plt.savefig(f"figures/time_per_epoch.pdf", dpi=300)
    plt.savefig(f"figures/time_per_epoch.png", dpi=300)
//  [python]
def format_time_results(df_all_epochs, unique_run_id):
    time_delta = df_all_epochs.groupby(unique_run_id)["time"].diff() * 60
    time_delta = time_delta[
        time_delta > 0
    ]  # Remove negative values coming from preemption
    total_time = time_delta.sum().item()
    print("Total compute time : " + str(total_time))
    time_result = time_delta.groupby(["dataset", "method", "#HP", "Groups"]).median()
    average = (
        time_result.groupby(["method", "#HP", "Groups"]).mean().to_frame("Average")
    )
    time_result = time_result.unstack("dataset").sort_index(level="Groups")
    time_result = time_result.join(average).apply(lambda x: x.map("{:.2f}".format))
    print(time_result)
    time_result.to_latex(
        "tables/result_time_h.tex", escape=False, multirow=True, multicolumn=True
    )

    sns.set(style="whitegrid", context="talk")
    g = sns.catplot(
        data=time_delta.to_frame("time").reset_index(),
        x="method",
        y="time",
        col="dataset",
        kind="box",
        sharex=True,
        sharey=False,
        height=6,
        col_wrap=2,
    )
    for ax in g.fig.axes:
        ax.set_yscale("log")
        ax.tick_params(axis="x", labelrotation=45)
    g.set_axis_labels("Method", "Time per epoch in minutes")
    g.set_titles(col_template="{col_name}")
    g.tight_layout()
    plt.savefig(f"figures/time_per_epoch.pdf", dpi=300)
    plt.savefig(f"figures/time_per_epoch.png", dpi=300)
//  [python]
def plot_min_acc_dist(df, run_groups, n):
    dfs = []
    for idx, _ in df.iterrows():
        dfs.append(run_groups.get_group(idx)["min_acc_te"])
    df = pd.concat(dfs).sort_index(level="Groups")
    df = df.reindex(
        ["CelebA", "Waterbirds", "MultiNLI", "CivilComments"], level="dataset"
    ).reset_index()
    sns.set(style="whitegrid", context="talk", font="Times New Roman")
    g = sns.factorplot(
        data=df,
        x="method",
        y="min_acc_te",
        col="dataset",
        kind="box",
        sharex=True,
        sharey=False,
        size=4.5,
    )
    for ax in g.fig.axes:
        ax.tick_params(axis="x", labelrotation=45)
    g.set_axis_labels("Method", "worst-group-acc")
    g.set_titles(col_template="{col_name}")
    g.tight_layout()
    plt.savefig(f"figures/worst_group_acc_dist_dataset_{n}.pdf", dpi=300)
    plt.savefig(f"figures/worst_group_acc_dist_dataset_{n}.png", dpi=300)

    plt.figure()
    g = sns.factorplot(data=df, x="method", y="min_acc_te", kind="box", size=5.5)
    for ax in g.fig.axes:
        ax.tick_params(axis="x", labelrotation=45)
    g.set_axis_labels("Method", "worst-group-acc")
    g.tight_layout()
    plt.savefig(f"figures/worst_group_acc_dist_{n}.pdf", dpi=300)
    plt.savefig(f"figures/worst_group_acc_dist_{n}.png", dpi=300)
//  [python]
def plot_min_acc_dist(df, run_groups, n):
    dfs = []
    for idx, _ in df.iterrows():
        dfs.append(run_groups.get_group(idx)["min_acc_te"])
    df = pd.concat(dfs).sort_index(level="Groups")
    df = df.reindex(
        ["CelebA", "Waterbirds", "MultiNLI", "CivilComments"], level="dataset"
    ).reset_index()
    sns.set(style="whitegrid", context="talk", font="Times New Roman")
    g = sns.catplot(
        data=df,
        x="method",
        y="min_acc_te",
        col="dataset",
        kind="box",
        sharex=True,
        sharey=False,
        height=4.5,
    )
    for ax in g.fig.axes:
        ax.tick_params(axis="x", labelrotation=45)
    g.set_axis_labels("Method", "worst-group-acc")
    g.set_titles(col_template="{col_name}")
    g.tight_layout()
    plt.savefig(f"figures/worst_group_acc_dist_dataset_{n}.pdf", dpi=300)
    plt.savefig(f"figures/worst_group_acc_dist_dataset_{n}.png", dpi=300)

    plt.figure()
    g = sns.catplot(data=df, x="method", y="min_acc_te", kind="box", height=5.5)
    for ax in g.fig.axes:
        ax.tick_params(axis="x", labelrotation=45)
    g.set_axis_labels("Method", "worst-group-acc")
    g.tight_layout()
    plt.savefig(f"figures/worst_group_acc_dist_{n}.pdf", dpi=300)
    plt.savefig(f"figures/worst_group_acc_dist_{n}.png", dpi=300)
//  [python]
def barplot(self, data, args):
        assert all(map(lambda x: x in args, ['outfile', 'title']))

        # Reshape data
        df = data.dropna().reset_index(drop=True)
        df = df.melt(id_vars=['hyps_path', 'dset'])
        df.columns = ['Run', 'Dset', 'Metric', 'Score',]

        # Make plot
        f, ax = plt.subplots(figsize=(15, 15))
        ax = sns.factorplot(x='Metric', y='Score', hue='Run', data=df, 
            kind=args['kind'], palette="Pastel1", showfliers=False, hue_order=args['hue_order'])
        plt.xticks(rotation=60)
        plt.title(args['title'])
        plt.ylabel('Score')
        plt.subplots_adjust(bottom=0.25, right=0.7, top=0.9)
        plt.savefig(args['outfile'])
        plt.clf()
//  [python]
def barplot(self, data, args):
        assert all(map(lambda x: x in args, ['outfile', 'title']))

        # Reshape data
        df = data.dropna().reset_index(drop=True)
        df = df.melt(id_vars=['hyps_path', 'dset'])
        df.columns = ['Run', 'Dset', 'Metric', 'Score',]

        # Make plot
        f, ax = plt.subplots(figsize=(15, 15))
        ax = sns.catplot(x='Metric', y='Score', hue='Run', data=df, 
            kind=args['kind'], palette="Pastel1", showfliers=False, hue_order=args['hue_order'])
        plt.xticks(rotation=60)
        plt.title(args['title'])
        plt.ylabel('Score')
        plt.subplots_adjust(bottom=0.25, right=0.7, top=0.9)
        plt.savefig(args['outfile'])
        plt.clf()
//  [python]
def aggr_corr_barplot(self, df, args):
        df = df.copy()
        args['outfile'] = os.path.join(self.out_dir, 'figs', f'pubmed_aggr_corr_barplot.png')
        args['ylabel'] = 'Correlation of Eval Scores and Doc. Length \n (Pearson r)'
        
        # Preprocessing
        args['plot_title'] = f'Comparison of Correlations between Output Scores and Document Length by Model Length \n (PubMed test set)'
        df = df.melt(id_vars=['hyps_path', 'expr_name'])
        df.columns = ['Model length', "Start type", 'Metric', args['ylabel'],]
        df['Model length'] = df['Model length'].str[-4:]

        # Make plot
        data = df.loc[df['Model length'].isin(['1024', '2048', '3072', '4096'])]
        g = sns.factorplot(x="Metric", y=args['ylabel'], data=data, hue='Start type', kind='bar',
            palette='pastel', col="Model length", ci=None, col_wrap=2)

        plt.subplots_adjust(top=0.8)
        g.fig.suptitle(args['plot_title'])
        plt.savefig(args['outfile'])
        plt.clf()
//  [python]
def aggr_corr_barplot(self, df, args):
        df = df.copy()
        args['outfile'] = os.path.join(self.out_dir, 'figs', f'pubmed_aggr_corr_barplot.png')
        args['ylabel'] = 'Correlation of Eval Scores and Doc. Length \n (Pearson r)'
        
        # Preprocessing
        args['plot_title'] = f'Comparison of Correlations between Output Scores and Document Length by Model Length \n (PubMed test set)'
        df = df.melt(id_vars=['hyps_path', 'expr_name'])
        df.columns = ['Model length', "Start type", 'Metric', args['ylabel'],]
        df['Model length'] = df['Model length'].str[-4:]

        # Make plot
        data = df.loc[df['Model length'].isin(['1024', '2048', '3072', '4096'])]
        g = sns.catplot(x="Metric", y=args['ylabel'], data=data, hue='Start type', kind='bar',
            palette='pastel', col="Model length", ci=None, col_wrap=2)

        plt.subplots_adjust(top=0.8)
        g.fig.suptitle(args['plot_title'])
        plt.savefig(args['outfile'])
        plt.clf()
//  [python]
def plot_fraction_minorities(df_rank):
    fg = sns.factorplot(data=df_rank, x='rank', y='fmt', hue='kind', 
                     kind='point', palette='BrBG', size=3, aspect=1, legend_out=False,
                     estimator=np.mean, ci='sd')
    fg.ax.axhline(df_rank.query("kind=='empirical' & rank==100").fmt.values[0], ls='--', c='grey', lw=1.0)
//  [python]
def plot_fraction_minorities(df_rank):
    fg = sns.catplot(data=df_rank, x='rank', y='fmt', hue='kind', 
                     kind='point', palette='BrBG', height=3, aspect=1, legend_out=False,
                     estimator=np.mean, ci='sd')
    fg.ax.axhline(df_rank.query("kind=='empirical' & rank==100").fmt.values[0], ls='--', c='grey', lw=1.0)
//  [python]
def create_mt_plot(path: str):
    data = pd.read_csv(path, header=0, index_col=None)
    for idx, (target_data, target_scale) in enumerate([("MTNT", (8, 15)), ("UN", (30, 33))]):
        with sns.axes_style("whitegrid"):
            g = sns.factorplot(
                data=data, kind="bar",
                x="Method", y=f"Avg_{target_data}", hue="Setting",
                ci=None, legend=False, size=6, aspect=8/6
            )
            g.set_axis_labels("Method", "BLEU")
            plt.title(target_data)
            g.set(ylim=target_scale)
            # plt.legend(loc='upper left', title='Model Type')
            plt.tight_layout()
            plt.savefig(f"plots_and_data_for_paper/{target_data}_MT.png")
            plt.savefig(f"plots_and_data_for_paper/{target_data}_MT.pdf")
            plt.close()
            print("Done")
//  [python]
def create_mt_plot(path: str):
    data = pd.read_csv(path, header=0, index_col=None)
    for idx, (target_data, target_scale) in enumerate([("MTNT", (8, 15)), ("UN", (30, 33))]):
        with sns.axes_style("whitegrid"):
            g = sns.catplot(
                data=data, kind="bar",
                x="Method", y=f"Avg_{target_data}", hue="Setting",
                ci=None, legend=False, height=6, aspect=8/6, legend_out=True
            )
            g.set_axis_labels("Method", "BLEU")
            plt.title(target_data)
            g.set(ylim=target_scale)
            # plt.legend(loc='upper left', title='Model Type')
            plt.tight_layout()
            plt.savefig(f"plots_and_data_for_paper/{target_data}_MT.png")
            plt.savefig(f"plots_and_data_for_paper/{target_data}_MT.pdf")
            plt.close()
            print("Done")
//  [python]
def create_lm_plot(path: str):
    data = pd.read_csv(path, header=0, index_col=None)
    E_cols = [col for col in data.columns if "_E" == col[-2:]]
    U_cols = [col for col in data.columns if "_U" == col[-2:]]
    data["Europarl"] = data[E_cols].mean(axis=1)
    data["UN"] = data[U_cols].mean(axis=1)


    for idx, target_data in enumerate(["Europarl", "UN"]):
        with sns.axes_style("whitegrid"):
            g = sns.factorplot(
                data=data, kind="bar",
                x="Method", y=target_data, hue="Setting",
                ci=None, legend_out=False, legend=False, size=4, aspect=8/4
            )
            g.set_axis_labels("Method", "PPL")
            # plt.xticks(rotation=45)
            plt.title(target_data)
            if idx == 0:
                plt.legend(loc='upper left', title='Model Type')
            plt.tight_layout()
            plt.savefig(f"plots_and_data_for_paper/{target_data}_LM.png")
            plt.savefig(f"plots_and_data_for_paper/{target_data}_LM.pdf")
            plt.close()

    print("Done with LM Plots")
//  [python]
def create_lm_plot(path: str):
    data = pd.read_csv(path, header=0, index_col=None)
    E_cols = [col for col in data.columns if "_E" == col[-2:]]
    U_cols = [col for col in data.columns if "_U" == col[-2:]]
    data["Europarl"] = data[E_cols].mean(axis=1)
    data["UN"] = data[U_cols].mean(axis=1)


    for idx, target_data in enumerate(["Europarl", "UN"]):
        with sns.axes_style("whitegrid"):
            g = sns.catplot(
                data=data, kind="bar",
                x="Method", y=target_data, hue="Setting",
                ci=None, legend_out=False, legend=False, height=4, aspect=8/4
            )
            g.set_axis_labels("Method", "PPL")
            # plt.xticks(rotation=45)
            plt.title(target_data)
            if idx == 0:
                plt.legend(loc='upper left', title='Model Type')
            plt.tight_layout()
            plt.savefig(f"plots_and_data_for_paper/{target_data}_LM.png")
            plt.savefig(f"plots_and_data_for_paper/{target_data}_LM.pdf")
            plt.close()

    print("Done with LM Plots")
//  [python]
matplotlib.rcParams['ps.fonttype'] = 42

sns.set_style("whitegrid")
# sns.set_context("talk")
sns.set_context("notebook", font_scale=2, rc={"lines.linewidth": 2.5})

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

# fig.set_size_inches(8,6)
g = sns.barplot(
    data=merge2, x="context", y= 'methylation level', hue='group', palette="dark", 
    alpha=.6)
//  [python]
matplotlib.rcParams['ps.fonttype'] = 42

sns.set_style("whitegrid")
# sns.set_context("talk")
sns.set_context("notebook", font_scale=2, rc={"lines.linewidth": 2.5})

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

# fig.set_size_inches(8,6)
g = sns.catplot(
    data=merge2, kind="bar",
    x="context", y= 'methylation level', hue='group', palette="dark", 
    alpha=.6, height=6, legend = False)
//  [python]
def create_block_runtime_plots(blocks):
    f, axes = plt.subplots(1, 2, sharey=True)
    #axes[0].title('Block runtime grouped by Accession')
    sns.barplot(x='acc_id', y='align_runtime', data=blocks, ax=axes[0])

    #axes[1].title('Block runtime grouped by paired / unpaired')
    sns.barplot(x='contains_paired', y='align_runtime', data=blocks, ax=axes[1])

    #plt.savefig('grouped_block_times.svg'); plt.clf()
    plt.show()
//  [python]
def create_block_runtime_plots(blocks):
    f, axes = plt.subplots(1, 2, sharey=True)
    #axes[0].title('Block runtime grouped by Accession')
    sns.catplot(x='acc_id', y='align_runtime', data=blocks, ax=axes[0])

    #axes[1].title('Block runtime grouped by paired / unpaired')
    sns.catplot(x='contains_paired', y='align_runtime', data=blocks, ax=axes[1])

    #plt.savefig('grouped_block_times.svg'); plt.clf()
    plt.show()
//  [python]
sns.set(style="darkgrid")

# 2.1ʾ��
tips = sns.load_dataset("tips")
sns.barplot(x="day", y="total_bill", data=tips)
//  [python]
sns.set(style="darkgrid")

# 2.1ʾ��
tips = sns.load_dataset("tips")
sns.catplot(x="day", y="total_bill", data=tips)