jiahuimbzuai/CoQuIR huggingface dataset:
//  [python]
def subplot_data(data, ax, value="mean", title=None, min_score=None, max_score=None):
    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
    if min_score is not None and max_score is not None:
        scale = float(max_score) - float(min_score)
        data[value] = (data[value] - float(min_score))/scale
        min_data = np.min(data[value])
        max_data = np.max(data[value])
        min_data_q = np.round(min_data / 0.2)*0.2
        max_data_q = np.round(max_data / 0.2)*0.2
    sns.lineplot(data=data, x="Iteration", y=value, hue="Condition", units="Unit", ax=ax, estimator=None)
    ax.set_xlabel(None)
    ax.set_ylabel(None)
    if title is not None:
        plt.title(title)
    if min_score is not None and max_score is not None:
        ax.set_yticks(np.arange(min_data_q, max_data_q+0.2, 0.2))
    ax.xaxis.set_major_locator(MaxNLocator(integer=True))
    ax.get_legend().remove()
    return ax
//  [python]
def plot_data(data, value="AverageReturn"):
    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
    sns.set(style="darkgrid", font_scale=1.0)
    sns.tsplot(
        data=data,
        time="Iteration",
        value=value,
        unit="Unit",
        condition="Condition")
    plt.legend(loc='best').draggable()
    plt.show()
//  [python]
def plot_data(data, value="AverageReturn"):
    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
    sns.set(style="darkgrid", font_scale=1.0)
    sns.lineplot(
        data=data,
        x="Iteration",
        y=value,
        hue="Condition",
        units="Unit",
        estimator=None)
    plt.legend(loc='best').draggable()
    plt.show()
//  [python]
def show_fitness_history_all(history_runs, iterations, name_of_dataset=None, with_bands=False, save=True):
    color_to_take = cycle('bgrcmykw')
    iters = [it for it in range(iterations)]

    if not with_bands:
        for history in history_runs:
            sns.tsplot(history, iters, legend=True, color=next(color_to_take))
        plt.legend(labels=[idx for idx in range(len(history_runs))], loc='lower right')
    else:
        sns.tsplot(history_runs, iters, legend=True, color=next(color_to_take))
    plt.ylabel('Best ROC-AUC')
    plt.xlabel('Generation, #')
    plt.xticks([0, 5, 10, 15, 20, 25, 28])
    if save:
        if not os.path.isdir('../../tmp'):
            os.mkdir('../../tmp')

        file_name = name_of_dataset + '_fitness_history_all.png'
        path = f'../../tmp/{file_name}'
        plt.savefig(path, bbox_inches='tight')

    plt.show()
//  [python]
def show_fitness_history_all(history_runs, iterations, name_of_dataset=None, with_bands=False, save=True):
    color_to_take = cycle('bgrcmykw')
    iters = [it for it in range(iterations)]

    if not with_bands:
        for history in history_runs:
            sns.lineplot(iters, history, legend=True, color=next(color_to_take))
        plt.legend(labels=[idx for idx in range(len(history_runs))], loc='lower right')
    else:
        sns.lineplot(iters, history_runs, legend=True, color=next(color_to_take))
    plt.ylabel('Best ROC-AUC')
    plt.xlabel('Generation, #')
    plt.xticks([0, 5, 10, 15, 20, 25, 28])
    if save:
        if not os.path.isdir('../../tmp'):
            os.mkdir('../../tmp')

        file_name = name_of_dataset + '_fitness_history_all.png'
        path = f'../../tmp/{file_name}'
        plt.savefig(path, bbox_inches='tight')

    plt.show()
//  [python]
def show_history_optimization_comparison(optimisers_fitness_history: List[List[int]], iterations: List[int],
                                         labels: List[str], color_pallete: str = 'bgrcmykw', xlabel='Generation, #',
                                         ylabel='Best RMSE', name_of_dataset=None, save=True,
                                         task: Task = Task(TaskTypesEnum.classification)):
    loc = 'lower right'
    if task.task_type == TaskTypesEnum.regression:
        loc = 'upper right'
    fig_dims = (9, 7)
    fig, ax = plt.subplots(figsize=fig_dims)
    color_to_take = cycle(color_pallete)
    plt.yticks(fontsize=20)
    for fitness_history in optimisers_fitness_history:
        sns.tsplot(fitness_history, iterations, legend=True, color=next(color_to_take), ax=ax)
    # plt.xticks(range(0, max(iterations)), fontsize=13)
    plt.xticks(fontsize=20)
    plt.legend(labels=labels, loc=loc, fontsize=20)
    plt.ylabel(ylabel, fontsize=22)
    plt.xlabel(xlabel, fontsize=22)
    plt.tight_layout()
    if save:
        if not os.path.isdir('../../tmp'):
            os.mkdir('../../tmp')

        if ylabel == 'Hypervolume':
            file_name = name_of_dataset + '_Hypervolume_comparison.png'
        else:
            file_name = name_of_dataset + '_history_optimization_comparison.png'
        path = f'../../tmp/{file_name}'
        plt.savefig(path, bbox_inches='tight')

    plt.show()
//  [python]
def show_history_optimization_comparison(optimisers_fitness_history: List[List[int]], iterations: List[int],
                                         labels: List[str], color_pallete: str = 'bgrcmykw', xlabel='Generation, #',
                                         ylabel='Best RMSE', name_of_dataset=None, save=True,
                                         task: Task = Task(TaskTypesEnum.classification)):
    loc = 'lower right'
    if task.task_type == TaskTypesEnum.regression:
        loc = 'upper right'
    fig_dims = (9, 7)
    fig, ax = plt.subplots(figsize=fig_dims)
    color_to_take = cycle(color_pallete)
    plt.yticks(fontsize=20)
    for i, fitness_history in enumerate(optimisers_fitness_history):
        sns.lineplot(x=iterations, y=fitness_history, legend=True, color=next(color_to_take), ax=ax)
    # plt.xticks(range(0, max(iterations)), fontsize=13)
    plt.xticks(fontsize=20)
    plt.legend(labels=labels, loc=loc, fontsize=20)
    plt.ylabel(ylabel, fontsize=22)
    plt.xlabel(xlabel, fontsize=22)
    plt.tight_layout()
    if save:
        if not os.path.isdir('../../tmp'):
            os.mkdir('../../tmp')

        if ylabel == 'Hypervolume':
            file_name = name_of_dataset + '_Hypervolume_comparison.png'
        else:
            file_name = name_of_dataset + '_history_optimization_comparison.png'
        path = f'../../tmp/{file_name}'
        plt.savefig(path, bbox_inches='tight')

    plt.show()
//  [python]
def plot_data(data, value="AverageReturn"):
    print(data)
    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
    sns.set(style="darkgrid", font_scale=1.5)
    sns.tsplot(data=data, time="Iteration", value=value, unit="Unit", condition="Condition")
    plt.legend(loc='best').draggable()
    plt.show()
//  [python]
def plot_data(data, value="AverageReturn"):
    print(data)
    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
    sns.set(style="darkgrid", font_scale=1.5)
    sns.lineplot(data=data, x="Iteration", y=value, hue="Condition", units="Unit")
    plt.legend(loc='best').draggable()
    plt.show()
//  [python]
def plot_sentiment_series(videos, topics, channels, start_date=None, title=None):
    """
    Plot linear timeseries of sentiment scores for the given videos:
    One separate subplot is generated for each topic. Each subplot
    has one timeseries for each channel, and one timeseries for the
    average values across all channells.
    """
    fig, axes = plt.subplots(nrows=topics.shape[0], ncols=1, figsize=(8,4*topics.shape[0]))
    fig.subplots_adjust(hspace=.3)
    
    # Resample rule: 2-week buckets
    resample_rule = '2W'
    
    # Calculate the approximate amplitude of the given sentiment values
    amplitude = math.ceil(videos.sentiment_score.abs().max()*10)/10
    
    for i, topic in topics.reset_index().iterrows():
        ax = fig.axes[i]
        # Grey out the negative sentiment area
        ax.axhspan(0, -1, facecolor='0.2', alpha=0.15)

        # Plot a timeseries for the average sentiment across all channels
        topic_mask = videos[topic.slug]
        if start_date is not None:
            topic_mask = topic_mask & (videos.published_at >= start_date)
        ts = videos[topic_mask].set_index('published_at').resample(resample_rule)['sentiment_score'].mean().interpolate()
        sns.tsplot(ts, ts.index, color='#fcef99', linewidth=6, ax=ax)
        
        # Plot a separate time-series for each channel
        for _, channel in channels.iterrows():
            channel_mask = topic_mask & (videos.channel==channel.title)
            ts = videos[channel_mask].set_index('published_at').resample(resample_rule)['sentiment_score'].mean().interpolate()
            if len(ts) > 1:
                sns.tsplot(ts, ts.index, color=channel['color'], linewidth=1, ax=ax)

        # Format x-axis labels as dates
        xvalues = ax.xaxis.get_majorticklocs()
        xlabels = [datetime.utcfromtimestamp(x/1e9).strftime("%Y.%m") for x in xvalues]
        ax.set_xticklabels(xlabels)

        # A little extra presentation cleanup
        ax.set_xlabel('')
        ax.set_title(topic['title'], size=11)
        ax.set_ylim(-amplitude,amplitude)

        # Add legend
        handles = [Patch(color='#fcef99', label='Average')]
        for _, channel in channels.iterrows():
            handles.append(Patch(color=channel['color'], label=channel['title']))
        ax.legend(handles=handles, fontsize=8)

    # Optional title at the top
    if title is not None:
        plt.suptitle(title, size=14, y=.92)
        
    plt.show()
//  [python]
def plot_sentiment_series(videos, topics, channels, start_date=None, title=None):
    """
    Plot linear timeseries of sentiment scores for the given videos:
    One separate subplot is generated for each topic. Each subplot
    has one timeseries for each channel, and one timeseries for the
    average values across all channells.
    """
    fig, axes = plt.subplots(nrows=topics.shape[0], ncols=1, figsize=(8,4*topics.shape[0]))
    fig.subplots_adjust(hspace=.3)
    
    # Resample rule: 2-week buckets
    resample_rule = '2W'
    
    # Calculate the approximate amplitude of the given sentiment values
    amplitude = math.ceil(videos.sentiment_score.abs().max()*10)/10
    
    for i, topic in topics.reset_index().iterrows():
        ax = fig.axes[i]
        # Grey out the negative sentiment area
        ax.axhspan(0, -1, facecolor='0.2', alpha=0.15)

        # Plot a timeseries for the average sentiment across all channels
        topic_mask = videos[topic.slug]
        if start_date is not None:
            topic_mask = topic_mask & (videos.published_at >= start_date)
        ts = videos[topic_mask].set_index('published_at').resample(resample_rule)['sentiment_score'].mean().interpolate()
        sns.lineplot(x=ts.index, y=ts.values, color='#fcef99', linewidth=6, ax=ax)
        
        # Plot a separate time-series for each channel
        for _, channel in channels.iterrows():
            channel_mask = topic_mask & (videos.channel==channel.title)
            ts = videos[channel_mask].set_index('published_at').resample(resample_rule)['sentiment_score'].mean().interpolate()
            if len(ts) > 1:
                sns.lineplot(x=ts.index, y=ts.values, color=channel['color'], linewidth=1, ax=ax)

        # Format x-axis labels as dates
        xvalues = ax.xaxis.get_majorticklocs()
        xlabels = [datetime.utcfromtimestamp(x/1e9).strftime("%Y.%m") for x in xvalues]
        ax.set_xticklabels(xlabels)

        # A little extra presentation cleanup
        ax.set_xlabel('')
        ax.set_title(topic['title'], size=11)
        ax.set_ylim(-amplitude,amplitude)

        # Add legend
        handles = [Patch(color='#fcef99', label='Average')]
        for _, channel in channels.iterrows():
            handles.append(Patch(color=channel['color'], label=channel['title']))
        ax.legend(handles=handles, fontsize=8)

    # Optional title at the top
    if title is not None:
        plt.suptitle(title, size=14, y=.92)
        
    plt.show()
//  [python]
def plot_results(df, figsize=(6, 3), sharey=True):
    with sns.axes_style('ticks'):

        _ = plt.figure(figsize=figsize)
        gs = gridspec.GridSpec(1, 2, width_ratios=[1.8, 1], wspace=0.4)

        ax0 = plt.subplot(gs[0])
        ax1 = plt.subplot(gs[1])

        # define the parameters to plot the results
        # cc = sns.color_palette("Set 2")
        df0 = df[df['In goal']].groupby(['Model', 'Simulation Number', 'Trial Number']).mean()
        df0 = df0.groupby(level=[0, 1]).cumsum().reset_index()
        df0 = df0.rename(index=str, columns={'n actions taken': "Cumulative Steps Taken"})

        tsplot_kwargs = dict(
            time='Trial Number',
            value='Cumulative Steps Taken',
            data=df0,
            unit='Simulation Number',
            condition='Model',
            estimator=np.mean,
            ax=ax0,
            color="Set2",
        )

        sns.tsplot(**tsplot_kwargs)
        df0 = df[df['In goal']].groupby(['Model', 'Simulation Number']).sum()
        cum_steps = [df0.loc[m]['n actions taken'].values for m in set(df.Model)]
        model = []
        for m in set(df.Model):
            model += [m] * (df[df.Model == m]['Simulation Number'].max() + 1)
        df1 = pd.DataFrame({
                'Cumulative Steps Taken': np.concatenate(cum_steps),
                'Model': model
            })

        sns.violinplot(data=df1, x='Model', y='Cumulative Steps Taken', ax=ax1, palette='Set2',
                       order=["Flat", "Independent", "Joint"]
                       )

        _, ub = ax1.get_ylim()
        ax1.set_ylim([0, ub])
        if sharey is True:
            _, ub = ax0.get_ylim()
            ax0.set_ylim([0, ub])


        sns.despine(offset=5)
//  [python]
def plot_results(df, figsize=(6, 3), sharey=True):
    with sns.axes_style('ticks'):

        _ = plt.figure(figsize=figsize)
        gs = gridspec.GridSpec(1, 2, width_ratios=[1.8, 1], wspace=0.4)

        ax0 = plt.subplot(gs[0])
        ax1 = plt.subplot(gs[1])

        # define the parameters to plot the results
        # cc = sns.color_palette("Set 2")
        df0 = df[df['In goal']].groupby(['Model', 'Simulation Number', 'Trial Number']).mean()
        df0 = df0.groupby(level=[0, 1]).cumsum().reset_index()
        df0 = df0.rename(index=str, columns={'n actions taken': "Cumulative Steps Taken"})

        sns.lineplot(
            x='Trial Number',
            y='Cumulative Steps Taken',
            data=df0,
            hue='Model',
            estimator=np.mean,
            ax=ax0,
            palette="Set2",
            ci=None,
            units='Simulation Number',
            err_style=None
        )


        df0 = df[df['In goal']].groupby(['Model', 'Simulation Number']).sum()
        cum_steps = [df0.loc[m]['n actions taken'].values for m in set(df.Model)]
        model = []
        for m in set(df.Model):
            model += [m] * (df[df.Model == m]['Simulation Number'].max() + 1)
        df1 = pd.DataFrame({
                'Cumulative Steps Taken': np.concatenate(cum_steps),
                'Model': model
            })

        sns.violinplot(data=df1, x='Model', y='Cumulative Steps Taken', ax=ax1, palette='Set2',
                       order=["Flat", "Independent", "Joint"]
                       )

        _, ub = ax1.get_ylim()
        ax1.set_ylim([0, ub])
        if sharey is True:
            _, ub = ax0.get_ylim()
            ax0.set_ylim([0, ub])


        sns.despine(offset=5)
//  [python]
def show_results(env_name):
    from run_imitation_learning import get_epoch_grid_configs

    pickle_name = 'data/{}-DAgger-rewards.p'.format(env_name)
    returns = pickle.load(open(pickle_name, 'rb'))

    their_data = pickle.load(open('data/{}-their.p'.format(env_name), 'rb'))['returns']
    their_data = np.array([their_data for _ in xrange(len(returns.keys()))]).T

    acc = {}
    configs = get_epoch_grid_configs(env_name)
    for config in configs:
        data = pickle.load(open(config['our_data_path'], 'rb'))['returns']
        lr = config['epochs']
        acc[lr] = data

    vanilla_data = pd.DataFrame(acc)

    df = pd.DataFrame(returns)

    sns.tsplot(time=vanilla_data.columns, data=vanilla_data.values, color='purple', linestyle=':')
    sns.tsplot(time=df.columns, data=df.values, color='blue', linestyle='-')
    sns.tsplot(data=their_data, color='red', linestyle='--')

    plt.ylabel("Mean reward")
    plt.xlabel("Number of epochs (vanilla cloning), number of iterations (DAgger)")

    plt.title("{} - Comparison of DAgger and vanilla behavioral cloning policies".format(env_name))

    # dirty hack for fix a legend not showing up..
    import matplotlib.patches as mpatches
    plt.legend(handles=[
        mpatches.Patch(color='purple', label='Vanilla cloning policy'),
        mpatches.Patch(color='blue', label='DAgger policy'),
        mpatches.Patch(color='red', label='expert policy'),
    ], loc='lower right')

    plt.savefig('imgs/dagger-vanilla-comp-{}.png'.format(env_name))
    plt.close()
//  [python]
def show_results(env_name):
    from run_imitation_learning import get_epoch_grid_configs

    pickle_name = 'data/{}-DAgger-rewards.p'.format(env_name)
    returns = pickle.load(open(pickle_name, 'rb'))

    their_data = pickle.load(open('data/{}-their.p'.format(env_name), 'rb'))['returns']
    their_data = np.array([their_data for _ in xrange(len(returns.keys()))]).T

    acc = {}
    configs = get_epoch_grid_configs(env_name)
    for config in configs:
        data = pickle.load(open(config['our_data_path'], 'rb'))['returns']
        lr = config['epochs']
        acc[lr] = data

    vanilla_data = pd.DataFrame(acc)

    df = pd.DataFrame(returns)

    sns.lineplot(data=vanilla_data.values, x=vanilla_data.columns, color='purple', linestyle=':')
    sns.lineplot(data=df.values, x=df.columns, color='blue', linestyle='-')
    sns.lineplot(data=their_data, x=range(len(their_data)), color='red', linestyle='--')

    plt.ylabel("Mean reward")
    plt.xlabel("Number of epochs (vanilla cloning), number of iterations (DAgger)")

    plt.title("{} - Comparison of DAgger and vanilla behavioral cloning policies".format(env_name))

    # dirty hack for fix a legend not showing up..
    import matplotlib.patches as mpatches
    plt.legend(handles=[
        mpatches.Patch(color='purple', label='Vanilla cloning policy'),
        mpatches.Patch(color='blue', label='DAgger policy'),
        mpatches.Patch(color='red', label='expert policy'),
    ], loc='lower right')

    plt.savefig('imgs/dagger-vanilla-comp-{}.png'.format(env_name))
    plt.close()
//  [python]
def visualize(self, tsv_name, lower_axis=0, higher_axis=1):
        """
        Given a CSV file that has clusters, visualize each of those clusters based on the original normalized values.

        :param tsv_name:    The name of the TSV file to visualize the clusters of
        :param lower_axis:  The lower bound of each graph, default 0
        :param higher_axis: The upper bound of each graph, default 1
        :return:
        """
        visualization_path = os.path.join(self.output_directory, "Visualizations")
        if not os.path.exists(visualization_path):
            os.makedirs(visualization_path)
        if self.verbose:
            print("Loading large CSV into dataframe")
        df = pd.DataFrame.from_csv(os.path.join(self.output_directory, tsv_name + magic.default_output_file_ending),
                                   index_col=None,
                                   sep=magic.separator)

        if self.verbose:
            print("Finished loading CSV into dataframe")

        for ci in range(0, self.number_of_clusters):
            cluster = df[df["cluster"] == ci]
            if self.verbose:
                print("Cluster {}".format(ci))

            # If a header cannot be imported as an int, we drop it.
            # Therefore, any non-time headers in our current setup will be
            # dropped leaving us with only the time headers.
            drop_headers = []
            for header in df.columns.values:
                try:
                    int(header)
                except ValueError:
                    drop_headers.append(header)
            just_time_values = cluster.drop(drop_headers, 1)

            if self.verbose:
                print("Creating plot")
            if len(just_time_values) == 0:
                print("Cluster {} contained no values, skipping.".format(ci))
                continue

            sns.tsplot(just_time_values.as_matrix(), color="indianred", err_style="unit_traces")

            # Count first so we can order by count easily.
            save_location = os.path.join(visualization_path, "{}_Cluster_{}.png".format(ci, len(just_time_values)))
            if self.verbose:
                print("Saving plot at {}".format(save_location))

            sns.plt.ylim(lower_axis, higher_axis)
            sns.plt.title("Cluster Number {} - Count {}".format(ci, len(cluster)))
            sns.plt.savefig(save_location)

            # Make sure to clear after creating each figure.
            sns.plt.cla()
            sns.plt.clf()
//  [python]
def visualize(self, tsv_name, lower_axis=0, higher_axis=1):
        """
        Given a CSV file that has clusters, visualize each of those clusters based on the original normalized values.

        :param tsv_name:    The name of the TSV file to visualize the clusters of
        :param lower_axis:  The lower bound of each graph, default 0
        :param higher_axis: The upper bound of each graph, default 1
        :return:
        """
        visualization_path = os.path.join(self.output_directory, "Visualizations")
        if not os.path.exists(visualization_path):
            os.makedirs(visualization_path)
        if self.verbose:
            print("Loading large CSV into dataframe")
        df = pd.DataFrame.from_csv(os.path.join(self.output_directory, tsv_name + magic.default_output_file_ending),
                                   index_col=None,
                                   sep=magic.separator)

        if self.verbose:
            print("Finished loading CSV into dataframe")

        for ci in range(0, self.number_of_clusters):
            cluster = df[df["cluster"] == ci]
            if self.verbose:
                print("Cluster {}".format(ci))

            # If a header cannot be imported as an int, we drop it.
            # Therefore, any non-time headers in our current setup will be
            # dropped leaving us with only the time headers.
            drop_headers = []
            for header in df.columns.values:
                try:
                    int(header)
                except ValueError:
                    drop_headers.append(header)
            just_time_values = cluster.drop(drop_headers, 1)

            if self.verbose:
                print("Creating plot")
            if len(just_time_values) == 0:
                print("Cluster {} contained no values, skipping.".format(ci))
                continue

            sns.lineplot(data=just_time_values.T, color="indianred")

            # Count first so we can order by count easily.
            save_location = os.path.join(visualization_path, "{}_Cluster_{}.png".format(ci, len(just_time_values)))
            if self.verbose:
                print("Saving plot at {}".format(save_location))

            sns.plt.ylim(lower_axis, higher_axis)
            sns.plt.title("Cluster Number {} - Count {}".format(ci, len(cluster)))
            sns.plt.savefig(save_location)

            # Make sure to clear after creating each figure.
            sns.plt.cla()
            sns.plt.clf()
//  [python]
def plot_data(
    data,
    xaxis="Epoch",
    value="AverageEpRet",
    condition="Condition1",
    smooth=1,
    **kwargs
):
    if smooth > 1:
        """
        smooth data with moving window average.
        that is,
            smoothed_y[t] = average(y[t-k], y[t-k+1], ..., y[t+k-1], y[t+k])
        where the "smooth" param is width of that window (2k+1)
        """
        y = np.ones(smooth)
        for datum in data:
            x = np.asarray(datum[value])
            z = np.ones(len(x))
            smoothed_x = np.convolve(x, y, "same") / np.convolve(z, y, "same")
            datum[value] = smoothed_x

    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
    sns.set(style="darkgrid", font_scale=1.5)
    sns.tsplot(
        data=data,
        time=xaxis,
        value=value,
        unit="Unit",
        condition=condition,
        ci="sd",
        **kwargs
    )
    """
    If you upgrade to any version of Seaborn greater than 0.8.1, switch from 
    tsplot to lineplot replacing L29 with:

        sns.lineplot(data=data, x=xaxis, y=value, hue=condition, ci='sd', **kwargs)

    Changes the colorscheme and the default legend style, though.
    """
    plt.legend(loc="best").set_draggable(True)
    # plt.legend(loc='upper center', ncol=3, handlelength=1,
    #           borderaxespad=0., prop={'size': 13})

    """
    For the version of the legend used in the Spinning Up benchmarking page, 
    swap L38 with:

    plt.legend(loc='upper center', ncol=6, handlelength=1,
               mode="expand", borderaxespad=0., prop={'size': 13})
    """

    xscale = np.max(np.asarray(data[xaxis])) > 5e3
    if xscale:
        # Just some formatting niceness: x-axis scale in scientific notation if max x is large
        plt.ticklabel_format(style="sci", axis="x", scilimits=(0, 0))

    plt.tight_layout(pad=0.5)
//  [python]
def plot_data(
    data,
    xaxis="Epoch",
    value="AverageEpRet",
    condition="Condition1",
    smooth=1,
    **kwargs
):
    if smooth > 1:
        y = np.ones(smooth)
        for datum in data:
            x = np.asarray(datum[value])
            z = np.ones(len(x))
            smoothed_x = np.convolve(x, y, "same") / np.convolve(z, y, "same")
            datum[value] = smoothed_x

    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
    sns.set(style="darkgrid", font_scale=1.5)
    sns.lineplot(
        data=data,
        x=xaxis,
        y=value,
        hue=condition,
        ci="sd",
        **kwargs
    )
    plt.legend(loc="best").set_draggable(True)
    xscale = np.max(np.asarray(data[xaxis])) > 5e3
    if xscale:
        plt.ticklabel_format(style="sci", axis="x", scilimits=(0, 0))

    plt.tight_layout(pad=0.5)
//  [python]
matplotlib.rc('ytick', labelsize=20)


colors = [[1,0,1], [0,1,0], [0,0,1], [1,0,1]]
sns.set_style("whitegrid")
c = 0

for experiment in ["vanilla", "model"]:
    results_1, time = getdata("results/" + str(experiment), "4")

    # Plot each line.
    if "vanilla" in experiment:
        name = "QSA"
    else:
        name = "QSS"
    sns.tsplot(
        condition=f"{name}", time=time, data=results_1, color=colors[c], linestyle='-', err_style='ci_bars', interpolate=True, legend=True).set(xlim=(0, 50000))

    c += 1
//  [python]
matplotlib.rc('ytick', labelsize=20)


colors = [[1,0,1], [0,1,0], [0,0,1], [1,0,1]]
sns.set_style("whitegrid")
c = 0

for experiment in ["vanilla", "model"]:
    results_1, time = getdata("results/" + str(experiment), "4")

    # Plot each line.
    if "vanilla" in experiment:
        name = "QSA"
    else:
        name = "QSS"
    sns.lineplot(
        x=time, y=results_1, label=f"{name}", color=colors[c], err_style='bars').set(xlim=(0, 50000))

    c += 1
//  [python]
def show_feature(df):
    # showing the first 5 engines and the first five variables
    sns.pairplot(df[(df.unitid <=5) ],  hue="unitid",  vars=["set_1", "set_2",'sensor_2','sensor_3','sensor_4'])
    plt.show()

    #timeseries
    df1=df[(df.unitid <5) ]
    i=0
    for column in df1:
        if ('sensor' in column):
            i=i+1
            ax= plt.subplot(4,4,i)
            ax = sns.tsplot(time="time", value=column, condition='unitid',
                        unit='unitid',legend=False,
                        data=df1, ax=ax)    

    plt.show()
//  [python]
def show_feature(df):
    # showing the first 5 engines and the first five variables
    sns.pairplot(df[(df.unitid <=5) ],  hue="unitid",  vars=["set_1", "set_2",'sensor_2','sensor_3','sensor_4'])
    plt.show()

    #timeseries
    df1=df[(df.unitid <5) ]
    i=0
    for column in df1:
        if ('sensor' in column):
            i=i+1
            ax= plt.subplot(4,4,i)
            ax = sns.lineplot(x="time", y=column, hue='unitid',
                        data=df1, ax=ax)    

    plt.show()
//  [python]
def plot_data(data, logdir, xaxis='Epoch', value="AverageEpRet", condition="Condition1", smooth=1,
              show_label=False, **kwargs):
    if smooth > 1:
        y = np.ones(smooth)
        for datum in data:
            x = np.asarray(datum[value])
            z = np.ones(len(x))
            smoothed_x = np.convolve(x, y, 'same') / np.convolve(z, y, 'same')
            datum[value] = smoothed_x

    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
    sns.set(style="darkgrid", font_scale=2)
    simsr = data[data['Condition1']=='simsr']
    simsr_basic = data[data['Condition1']=='norm']
    sac_state = data[data['Condition1']=='SAC_state']
    sac_ae = data[data['Condition1']=='transition']
    curl = data[data['Condition1']=='CURL']
    deepmdp = data[data['Condition1']=='']
    dbc = data[data['Condition1']=='DBC']
    if not simsr_basic.empty:
        sns.lineplot(data=simsr_basic, x=xaxis, y=value, hue=condition, ci='sd', **kwargs)
    if not simsr.empty:
        sns.lineplot(data=simsr, x=xaxis, y=value, hue=condition, ci='sd', **kwargs)
    if not sac_state.empty:
        sns.lineplot(data=sac_state, x=xaxis, y=value, hue=condition, ci='sd', **kwargs)
    if not sac_ae.empty:
        sns.lineplot(data=sac_ae, x=xaxis, y=value, hue=condition, ci='sd', **kwargs)
    if not curl.empty:
        sns.lineplot(data=curl, x=xaxis, y=value, hue=condition, ci='sd', **kwargs)
    if not deepmdp.empty:
        sns.lineplot(data=deepmdp, x=xaxis, y=value, hue=condition, ci='sd', **kwargs)
    if not dbc.empty:
        sns.lineplot(data=dbc, x=xaxis, y=value, hue=condition, ci='sd', **kwargs)
    plt.legend(loc='lower right', fontsize='xx-small', labels=['SimSR', 'w/o $\ell_2$-normalization', 'w/ single probabilistic model']).set_draggable(True)
    plt.xlabel('Environment steps')
    plt.ylabel('AverageReturn')
    if not show_label:
        plt.legend().set_visible(False)
    print('============================================')
    xscale = np.max(np.asarray(data[xaxis])) > 5e3
    if xscale:
        plt.ticklabel_format(style='sci', axis='x', scilimits=(0, 0))

    plt.tight_layout(pad=0.5)
//  [python]
def plot_data(data, xaxis="Epoch", value="AverageEpRet", condition="Condition1", smooth=1, **kwargs):
	if smooth > 1:
		"""
		smooth data with moving window average.
		that is,
			smoothed_y[t] = average(y[t-k], y[t-k+1], ..., y[t+k-1], y[t+k])
		where the "smooth" param is width of that window (2k+1)
		"""
		y = np.ones(smooth)
		for datum in data:
			x = np.asarray(datum[value])
			z = np.ones(len(x))
			smoothed_x = np.convolve(x, y, "same") / np.convolve(z, y, "same")
			datum[value] = smoothed_x

	if isinstance(data, list):
		data = pd.concat(data, ignore_index=True)
	# For 6 algs 
	# flatui = ["#c34b4f", "#486fae", "#4fa563", "#8879b6", "#cab66d", "#5db2cb"]
	# sns.set(style="white", palette=sns.color_palette(flatui), font_scale=1.5)
	# For 5 algs
	# flatui = ["#c34b4f", "#4fa563", "#8879b6", "#cab66d", "#5db2cb", "#486fae",]
	# sns.set(style="white", palette=sns.color_palette(flatui), font_scale=1.5)
	# Default
	sns.set(style="white", font_scale=1.5)
	ax = sns.tsplot(data=data, time=xaxis, value=value, unit="Unit", condition=condition, ci="sd", **kwargs)
	ax.set_xlabel("Steps")
	"""
	If you upgrade to any version of Seaborn greater than 0.8.1, switch from 
	tsplot to lineplot replacing L29 with:

		sns.lineplot(data=data, x=xaxis, y=value, hue=condition, ci="sd", **kwargs)

	Changes the colorscheme and the default legend style, though.
	"""
	plt.legend(loc="best").set_draggable(True)
	plt.tick_params(direction="out", length=4)
	# plt.legend(loc="upper center", ncol=3, handlelength=1, borderaxespad=0., prop={"size": 13})

	"""
	For the version of the legend used in the Spinning Up benchmarking page, 
	swap L38 with:

	plt.legend(loc="upper center", ncol=6, handlelength=1,
			   mode="expand", borderaxespad=0., prop={"size": 13})
	"""

	xscale = np.max(np.asarray(data[xaxis])) > 5e3
	if xscale:
		# Just some formatting niceness: x-axis scale in scientific notation if max x is large
		plt.ticklabel_format(style="sci", axis='x', scilimits=(0, 0))

	plt.tight_layout(pad=0.5)
//  [python]
def plot_data(data, xaxis="Epoch", value="AverageEpRet", condition="Condition1", smooth=1, **kwargs):
	if smooth > 1:
		"""
		smooth data with moving window average.
		that is,
			smoothed_y[t] = average(y[t-k], y[t-k+1], ..., y[t+k-1], y[t+k])
		where the "smooth" param is width of that window (2k+1)
		"""
		y = np.ones(smooth)
		for datum in data:
			x = np.asarray(datum[value])
			z = np.ones(len(x))
			smoothed_x = np.convolve(x, y, "same") / np.convolve(z, y, "same")
			datum[value] = smoothed_x

	if isinstance(data, list):
		data = pd.concat(data, ignore_index=True)
	sns.set(style="white", font_scale=1.5)
	ax = sns.lineplot(data=data, x=xaxis, y=value, hue=condition, ci="sd", **kwargs)
	ax.set_xlabel("Steps")
	plt.legend(loc="best").set_draggable(True)
	plt.tick_params(direction="out", length=4)
	xscale = np.max(np.asarray(data[xaxis])) > 5e3
	if xscale:
		# Just some formatting niceness: x-axis scale in scientific notation if max x is large
		plt.ticklabel_format(style="sci", axis='x', scilimits=(0, 0))

	plt.tight_layout(pad=0.5)
//  [python]
def adapt2New(new_task_data,models,names):
    data = {'model': [], 'fits': [], 'loss': [], 'set': []}
    new_task_data
    for name, models in smodels:

        if not isinstance(models, list):

            models = [models]

        for n_model, model in enumerate(models):

            for n_test, test in enumerate(SINE_TEST):
                n_test = n_model * len(SINE_TEST) + n_test
                fit_res = eval_sine_test(model, test, fits, lr)

                for n, _, loss in fit_res:

                    data['model'].append(name)

                    data['fits'].append(n)

                    data['loss'].append(loss)

                    data['set'].append(n_test)

    
    print(len(data['loss']))
    ax = sbs.tsplot(
        pd.DataFrame(data), condition='model', value='loss',time='fits', unit='set', marker=marker, linestyle=linestyle)

    plt.show()
//  [python]
def adapt2New(new_task_data,models,names):
    data = {'model': [], 'fits': [], 'loss': [], 'set': []}
    new_task_data
    for name, models in smodels:

        if not isinstance(models, list):

            models = [models]

        for n_model, model in enumerate(models):

            for n_test, test in enumerate(SINE_TEST):
                n_test = n_model * len(SINE_TEST) + n_test
                fit_res = eval_sine_test(model, test, fits, lr)

                for n, _, loss in fit_res:

                    data['model'].append(name)

                    data['fits'].append(n)

                    data['loss'].append(loss)

                    data['set'].append(n_test)

    
    print(len(data['loss']))
    ax = sns.lineplot(
        data=pd.DataFrame(data), x='fits', y='loss', hue='model', units='set', marker=marker, estimator=None)

    plt.show()
//  [python]
matplotlib.rc('ytick', labelsize=20)
colors = [[1,0,0], [0,0,1], [0,1,0], [1,0,1]]

exp = "vanilla"
c = 0
for experiment in ["vanilla_shuffle", "model_shuffle", "vanilla_original_shuffled", "model_original_shuffled"]:
    for num_actions in [4]:
        results_1, time = getdata("results/" + str(experiment), num_actions)

        sns.set_style("whitegrid")
        color = colors[c]

        if "vanilla_shuffle" in experiment:
            name = "QSA transfer"
        elif "model_shuffle" in experiment:
            name = "QSS transfer"
        elif "vanilla_original" in experiment:
            name = "QSA scratch"
        else:
            name = "QSS scratch"

        # Plot each line.
        sns.tsplot(
            condition=str(name), time=time, data=results_1, color=color, linestyle='-', err_style='ci_bars', ci=95, interpolate=True, legend=True).set(xlim=(0, 10000))

        c += 1
//  [python]
matplotlib.rc('ytick', labelsize=20)
colors = [[1,0,0], [0,0,1], [0,1,0], [1,0,1]]

exp = "vanilla"
c = 0
for experiment in ["vanilla_shuffle", "model_shuffle", "vanilla_original_shuffled", "model_original_shuffled"]:
    for num_actions in [4]:
        results_1, time = getdata("results/" + str(experiment), num_actions)

        sns.set_style("whitegrid")
        color = colors[c]

        if "vanilla_shuffle" in experiment:
            name = "QSA transfer"
        elif "model_shuffle" in experiment:
            name = "QSS transfer"
        elif "vanilla_original" in experiment:
            name = "QSA scratch"
        else:
            name = "QSS scratch"

        # Plot each line.
        sns.lineplot(
            x=time, y=results_1, label=str(name), color=color, err_style='bars', ci=95).set(xlim=(0, 10000))

        c += 1
//  [python]
def plot_figure():
    remarks =  ['Normal_DDPG', 'PER_DDPG', 'Normal_TD3', 'PER_TD3']
    colors = ['r', 'g', 'b', 'black']
    labels = ['DDPG', 'DDPG+PER', 'TD3', 'TD3+PER']

    plt.figure()
    for remark, color, label in zip(remarks, colors, labels):
        time, data = load_data(remark=remark)
        sns.tsplot(time=time, data=data, color=color, condition=label)

    plt.grid()
    plt.xlabel('Total steps', fontsize='x-large')
    plt.ylabel('Average reward', fontsize='x-large')
    plt.show()
//  [python]
def plot_figure():
    remarks =  ['Normal_DDPG', 'PER_DDPG', 'Normal_TD3', 'PER_TD3']
    colors = ['r', 'g', 'b', 'black']
    labels = ['DDPG', 'DDPG+PER', 'TD3', 'TD3+PER']

    plt.figure()
    for remark, color, label in zip(remarks, colors, labels):
        time, data = load_data(remark=remark)
        sns.lineplot(x=time, y=data, color=color, label=label)

    plt.grid()
    plt.xlabel('Total steps', fontsize='x-large')
    plt.ylabel('Average reward', fontsize='x-large')
    plt.show()
//  [python]
def plot( self):
        sns.tsplot(data=self.pdo, time="alpha", unit="unit", condition="Method", value="r2")
        plt.xscale('log')
        plt.ylabel( r'$r^2$')
//  [python]
def plot( self):
        sns.lineplot(data=self.pdo, x="alpha", y="r2", hue="Method", units="unit")
        plt.xscale('log')
        plt.ylabel( r'$r^2$')
//  [python]
def col_ts_plot(val, ts, df):
    import matplotlib.dates as mdates
    df['Date_mpl'] = df[ts].apply(lambda x: mdates.date2num(x))
    fig, ax = plt.subplots(figsize=(12, 8))
    sns.tsplot(df[val].values, time=df.Date_mpl.values, alpha=0.8, color=color[3], ax=ax)
    ax.xaxis.set_major_locator(mdates.AutoDateLocator())
    ax.xaxis.set_major_formatter(mdates.DateFormatter("%Y.%m.%d"))
    fig.autofmt_xdate()
    plt.xlabel('Date', fontsize=12)
    plt.ylabel('Price', fontsize=12)
    plt.title('Closing price distribution of bitcoin', fontsize=15)
    plt.show()
//  [python]
def col_ts_plot(val, ts, df):
    import matplotlib.dates as mdates
    df['Date_mpl'] = df[ts].apply(lambda x: mdates.date2num(x))
    fig, ax = plt.subplots(figsize=(12, 8))
    sns.lineplot(x=df.Date_mpl.values, y=df[val].values, alpha=0.8, color=color[3], ax=ax)
    ax.xaxis.set_major_locator(mdates.AutoDateLocator())
    ax.xaxis.set_major_formatter(mdates.DateFormatter("%Y.%m.%d"))
    fig.autofmt_xdate()
    plt.xlabel('Date', fontsize=12)
    plt.ylabel('Price', fontsize=12)
    plt.title('Closing price distribution of bitcoin', fontsize=15)
    plt.show()
//  [python]
def plot_data(data, xaxis='Epoch', value="AverageEpRet", condition="Condition1", smooth=1, no_legend=False, legend_loc='best', color=None, **kwargs):
    if smooth > 1:
        """
        smooth data with moving window average.
        that is,
            smoothed_y[t] = average(y[t-k], y[t-k+1], ..., y[t+k-1], y[t+k])
        where the "smooth" param is width of that window (2k+1)
        """
        y = np.ones(smooth)
        for datum in data:
            x = np.asarray(datum[value])
            z = np.ones(len(x))
            smoothed_x = np.convolve(x,y,'same') / np.convolve(z,y,'same')
            datum[value] = smoothed_x

    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
    sns.set(style="darkgrid", font_scale=1.5)
    # sns.set_palette('bright')

    print("##############")

    ## TODO CHANGE BACK
    sns.tsplot(data=data, time=xaxis, value=value, unit="Unit", condition=condition, legend=(not no_legend), ci='sd', n_boot=0, color=color, **kwargs)
    plt.xlabel('environment interactions')
    plt.ylabel('average test return')

    """
    If you upgrade to any version of Seaborn greater than 0.8.1, switch from 
    tsplot to lineplot replacing L29 with:

        sns.lineplot(data=data, x=xaxis, y=value, hue=condition, ci='sd', **kwargs)

    Changes the colorscheme and the default legend style, though.
    """
    if not no_legend:
        plt.legend(loc=legend_loc).draggable()

    """
    For the version of the legend used in the Spinning Up benchmarking page, 
    swap L38 with:

    plt.legend(loc='upper center', ncol=6, handlelength=1,
               mode="expand", borderaxespad=0., prop={'size': 13})
    """

    xscale = np.max(np.asarray(data[xaxis])) > 5e3
    if xscale:
        # Just some formatting niceness: x-axis scale in scientific notation if max x is large
        plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))

    plt.tight_layout(pad=0.5)
//  [python]
def plot_data(data, xaxis='Epoch', value="AverageEpRet", condition="Condition1", smooth=1, no_legend=False, legend_loc='best', color=None, **kwargs):
    if smooth > 1:
        """
        smooth data with moving window average.
        that is,
            smoothed_y[t] = average(y[t-k], y[t-k+1], ..., y[t+k-1], y[t+k])
        where the "smooth" param is width of that window (2k+1)
        """
        y = np.ones(smooth)
        for datum in data:
            x = np.asarray(datum[value])
            z = np.ones(len(x))
            smoothed_x = np.convolve(x,y,'same') / np.convolve(z,y,'same')
            datum[value] = smoothed_x

    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
    sns.set(style="darkgrid", font_scale=1.5)
    # sns.set_palette('bright')

    print("##############")

    sns.lineplot(data=data, x=xaxis, y=value, hue=condition, ci='sd', **kwargs)
    plt.xlabel('environment interactions')
    plt.ylabel('average test return')

    if not no_legend:
        plt.legend(loc=legend_loc).draggable()

    xscale = np.max(np.asarray(data[xaxis])) > 5e3
    if xscale:
        # Just some formatting niceness: x-axis scale in scientific notation if max x is large
        plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))

    plt.tight_layout(pad=0.5)
//  [python]
def plot_data(data, xaxis='timesteps', value="Performance", condition="Condition1", smooth=1, **kwargs):
    if smooth > 1:
        y = np.ones(smooth)
        for datum in data:
            x = np.asarray(datum[value])
            z = np.ones(len(x))
            smoothed_x = np.convolve(x, y, 'same') / np.convolve(z, y, 'same')
            datum[value] = smoothed_x
    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
    fig = plt.figure(kwargs['figname'], figsize=(8, 6))
    sns.set(style="darkgrid", font_scale=2)
    sns.tsplot(data=data, time=xaxis, value=value, unit="Unit", condition=condition, ci='sd',)
    plt.xlabel(kwargs['xlabel'])
    plt.ylabel(kwargs['ylabel'])
    plt.legend(loc='best', fontsize=24 ).set_draggable(True)
    xscale = np.max(np.asarray(data[xaxis])) > 5e3
    if xscale:
        # Just some formatting niceness: x-axis scale in scientific notation if max x is large
        plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))
    axis = plt.gca()
    if not kwargs['disable_vline']:
        axis.axvline(100000, color='c', lw=1)
        axis.axvline(500000, color='r', lw=1)
    plt.tight_layout(pad=0.5)

    figdir = 'data/figs'
    os.makedirs(figdir, exist_ok=True)
    figname = osp.join(figdir, '{}.pdf'.format(kwargs['figname']))
    fig.savefig(figname, format='pdf')
    plt.show()
//  [python]
def plot_data(data, xaxis='timesteps', value="Performance", condition="Condition1", smooth=1, **kwargs):
    if smooth > 1:
        y = np.ones(smooth)
        for datum in data:
            x = np.asarray(datum[value])
            z = np.ones(len(x))
            smoothed_x = np.convolve(x, y, 'same') / np.convolve(z, y, 'same')
            datum[value] = smoothed_x
    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)
    fig = plt.figure(kwargs['figname'], figsize=(8, 6))
    sns.set(style="darkgrid", font_scale=2)
    sns.lineplot(data=data, x=xaxis, y=value, hue=condition, ci='sd', )
    plt.xlabel(kwargs['xlabel'])
    plt.ylabel(kwargs['ylabel'])
    plt.legend(loc='best', fontsize=24 ).set_draggable(True)
    xscale = np.max(np.asarray(data[xaxis])) > 5e3
    if xscale:
        # Just some formatting niceness: x-axis scale in scientific notation if max x is large
        plt.ticklabel_format(style='sci', axis='x', scilimits=(0,0))
    axis = plt.gca()
    if not kwargs['disable_vline']:
        axis.axvline(100000, color='c', lw=1)
        axis.axvline(500000, color='r', lw=1)
    plt.tight_layout(pad=0.5)

    figdir = 'data/figs'
    os.makedirs(figdir, exist_ok=True)
    figname = osp.join(figdir, '{}.pdf'.format(kwargs['figname']))
    fig.savefig(figname, format='pdf')
    plt.show()
//  [python]
def plot_log(result_file):
    fig = plt.figure()
    df = pd.read_csv(result_file)
    sns.tsplot(time=df['step'], data=df['ADV'], color='r', condition='ADV')
    plt.show()
//  [python]
def plot_log(result_file):
    fig = plt.figure()
    df = pd.read_csv(result_file)
    sns.lineplot(x=df['step'], y=df['ADV'], color='r', label='ADV')
    plt.show()
//  [python]
def plot_rates(df, time_name="Number of Noise Terms", value_name="Hit Rate", \
               unit_name="Iteration Id", condition_name="Number of Results",
               plot_path="results/hit_rates.pdf"):
    # plot as a pdf file
    with PdfPages(plot_path) as pdf:
        fig, ax = plt.subplots(1, 1)
        sns.tsplot(time=time_name, value=value_name, unit=unit_name, \
                   condition=condition_name, data=df, interpolate=True)
        pdf.savefig(fig)
//  [python]
def plot_rates(df, time_name="Number of Noise Terms", value_name="Hit Rate", \
               unit_name="Iteration Id", condition_name="Number of Results",
               plot_path="results/hit_rates.pdf"):
    # plot as a pdf file
    with PdfPages(plot_path) as pdf:
        fig, ax = plt.subplots(1, 1)
        sns.lineplot(x=time_name, y=value_name, hue=condition_name, units=unit_name, data=df, ci=None, estimator=None, lw=1)
        pdf.savefig(fig)
//  [python]
def plot_data(data, value="MeanReward100Episodes", save_name="results", title="Pong"):
    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)

    plt.figure()
    # sns.set(style="darkgrid", font_scale=1.5)
    sns.tsplot(data=data, time="Timestep", value=value, unit="Unit", condition="Condition", lw=2, alpha=1)
    plt.xlabel('Time step', fontsize=20)
    plt.ylabel('Average score', fontsize=20)
    plt.legend(loc='best', fontsize=15).draggable()
    plt.title(title, fontsize=20)
    ax = plt.axes()
    ax.tick_params(direction='in')
    plt.grid()
    plt.tick_params(labelsize=15)
    plt.show()
    plt.savefig(
        os.path.join('results/final', save_name + '.pdf'),
        bbox_inches='tight',
        transparent=True,
        pad_inches=0.1
    )
//  [python]
def plot_data(data, value="MeanReward100Episodes", save_name="results", title="Pong"):
    if isinstance(data, list):
        data = pd.concat(data, ignore_index=True)

    plt.figure()
    # sns.set(style="darkgrid", font_scale=1.5)
    sns.lineplot(data=data, x="Timestep", y=value, hue="Condition", units="Unit", lw=2, alpha=1)
    plt.xlabel('Time step', fontsize=20)
    plt.ylabel('Average score', fontsize=20)
    plt.legend(loc='best', fontsize=15).draggable()
    plt.title(title, fontsize=20)
    ax = plt.axes()
    ax.tick_params(direction='in')
    plt.grid()
    plt.tick_params(labelsize=15)
    plt.show()
    plt.savefig(
        os.path.join('results/final', save_name + '.pdf'),
        bbox_inches='tight',
        transparent=True,
        pad_inches=0.1
    )