//  [python]
def plot_data(data, logdir, xaxis='Epoch', value="AverageEpRet", condition="Condition1", smooth=1,
              show_label=False, **kwargs):
    # print(condition)
    # print(data)
    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=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.tsplot(data=simsr_basic, time=xaxis, value=value, unit="Unit", color='#1b9e77',
                   condition=condition, ci='sd', **kwargs)
    if not simsr.empty:
        sns.tsplot(data=simsr, time=xaxis, value=value, unit="Unit", color='#d95f02',
                   condition=condition, ci='sd', **kwargs)
    if not sac_state.empty:
        sns.tsplot(data=sac_state, time=xaxis, value=value, unit="Unit", color='#7570b3',
                   condition=condition, ci='sd', **kwargs)
    if not sac_ae.empty:
        sns.tsplot(data=sac_ae, time=xaxis, value=value, unit="Unit", color='gray',
                   condition=condition, ci='sd', **kwargs)
    if not curl.empty:
        sns.tsplot(data=curl, time=xaxis, value=value, unit="Unit", color='#66a61e',
                   condition=condition, ci='sd', **kwargs)
    if not deepmdp.empty:
        sns.tsplot(data=deepmdp, time=xaxis, value=value, unit="Unit", color='#e6ab02',
                   condition=condition, ci='sd', **kwargs)
    if not dbc.empty:
        sns.tsplot(data=dbc, time=xaxis, value=value, unit="Unit", color='#a6761d',
                   condition=condition, ci='sd', **kwargs)
    # else:
    # flatui = ["#9b59b6", "#3498db", "#95a5a6",
    #           "#e74c3c", "#34495e", "#2ecc71", "darkgoldenrod"]

    #flatui = ["#1b9e77", "#d95f02", "#7570b3",
    #          "#e7298a", "#66a61e", "#e6ab02", "#a6761d", "gray"]
    #ax = sns.tsplot(data=data, time=xaxis, value=value, unit="Unit", color=sns.color_palette(flatui),
    #           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.
    """
    #if logdir == 'cartpole_swingup':
    #	plt.axhline(y=740.0, color="#e6ab02", linestyle="--", label="dbc")
    #elif logdir == 'cheetah_run':
    #	plt.axhline(y=740.0, color="#e6ab02", linestyle="--", label="dbc")
    #elif logdir == 'finger_spin':
    #	plt.axhline(y=830.0, color="#e6ab02", linestyle="--", label="dbc")
    #elif logdir == 'hopper_hop':
    #	plt.axhline(y=70.0, color="#e6ab02", linestyle="--", label="dbc")
    #elif logdir == 'hopper_stand':
    #	plt.axhline(y=600.0, color="#e6ab02", linestyle="--", label="dbc")
    #elif logdir == 'walker_run':
    #	plt.axhline(y=330.0, color="#e6ab02", linestyle="--", label="dbc")
    #elif logdir == 'walker_stand':
    #	plt.axhline(y=950.0, color="#e6ab02", linestyle="--", label="dbc")
    #elif logdir == 'walker_walk':
    #	plt.axhline(y=800.0, color="#e6ab02", linestyle="--", label="dbc")
    #elif logdir == 'reacher_easy':
    #	plt.axhline(y=180.0, color="#e6ab02", linestyle="--", label="dbc")

    #handles, labels = ax.get_legend_handles_labels()
    #labels.append('dbc')
    #plt.legend(handles = handles, labels = labels)
    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('============================================')
    # 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)