plot_combo.py
def plot_single(args, goal_conditioned, name_task, name_plot):
    """Plot only one thing, similar to the table method.

    Let's not plot transporter-goal-snaive.
    """
    IGNORE = ['-transporter-goal-naive']

    # Override any parameters here.
    title_size = 40
    x_size = 38
    y_size = 38
    tick_size = 35
    legend_size = 25
    lw = 5
    ms = 12

    # Now make the plot.
    nrows, ncols = 1, 4
    fig, ax = plt.subplots(nrows, ncols, squeeze=True, figsize=(8.0*ncols, 9.0*nrows))
    title = f'Training Results, {name_plot}'
    supertitle = fig.suptitle(title, fontsize=title_size+2)

    for col, num_demos in enumerate([1, 10, 100, 1000]):
        # Extract all relevant subdirectories, and get results.
        directories, seeds = get_subdirectories_demos(name_task, num_demos)
        stats_combo = _get_results(name_task, directories, seeds, debug)

        # For each agent, plot. Iterate through keys of stats_combo[agent] IN ORDER.
        for agent in sorted(stats_combo.keys()):
            if agent in IGNORE:
                print(f'  ignoring {agent} for demos {num_demos}')
                continue
            x_vals = []
            y_vals = []
            y_errs = []  # standard deviations
            y_stde = []  # standard errors of mean
            print(f'on agent {agent} with keys {stats_combo[agent].keys()}')
            for itr in sorted(stats_combo[agent].keys()):
                x_vals.append( itr )
                values = stats_combo[agent][itr]
                if (len(values) != 60 and name_task != 'bag-color-goal' and itr != 0):
                    print(f'\tWarning, len(values): {len(values)} for: {agent}, {itr}')
                elif (len(values) != 20 and name_task == 'bag-color-goal'):
                    print(f'\tWarning, len(values): {len(values)} for: {agent}, {itr}')
                y_vals.append( np.mean(values) )
                y_errs.append( np.std(values) )
                y_stde.append( np.std(values) / np.sqrt(len(values)) )
            x_vals = np.array(x_vals)
            y_vals = np.array(y_vals)
            y_errs = np.array(y_errs)
            y_stde = np.array(y_stde)

            # NOTE: we're dividing by thousands here.
            x_vals = x_vals / 1000

            # Remove leading dash, and then plot, while clipping stdev's to range.
            ag = agent[1:]
            agent_label = AGENT_TO_LABEL[ag]
            color = AGENT_TO_COLOR[ag]
            if standard_error:
                lower = np.clip(y_vals - y_stde, 0.0 - EPS, 1.0 + EPS)
                upper = np.clip(y_vals + y_stde, 0.0 - EPS, 1.0 + EPS)
            else:
                lower = np.clip(y_vals - y_errs, 0.0 - EPS, 1.0 + EPS)
                upper = np.clip(y_vals + y_errs, 0.0 - EPS, 1.0 + EPS)
            ax[col].plot(x_vals, y_vals, lw=lw, color=color, ms=ms, marker='o', label=agent_label)
            ax[col].fill_between(x_vals, upper, lower, color=color, alpha=0.3, linewidth=0.0)
            ax[col].legend(prop={'size': legend_size})

        # Bells and whistles. For y-axis label, just put it on the leftmost column.
        subplot_title = f'Train Demos: {num_demos}'
        ax[col].set_title(subplot_title, fontsize=title_size)
        ax[col].set_xlabel(xlabel, fontsize=x_size)
        ylabel = 'Success Rate'
        if not args.binary:
            if name_task in ['cloth-flat', 'cloth-flat-notarget']:
                ylabel = 'Zone Coverage'
            elif name_task in ['cable-shape', 'cable-shape-notarget', 'cable-line-notarget']:
                ylabel = 'Percent in Zone'
        if col == 0:
            ax[col].set_ylabel(ylabel, fontsize=y_size)
        ax[col].set_ylim([0.0 - EPS, 1.0 + EPS])
        ax[col].tick_params(axis='x', labelsize=tick_size)
        ax[col].tick_params(axis='y', labelsize=tick_size)

    # Shift subplots down due to supertitle.
    plt.tight_layout()
    supertitle.set_y(0.98)
    fig.subplots_adjust(top=0.85)

    # Save file.
    suffix = f'plot_demos_task_{name_task}_v02.png'
    fname = join(os.getcwd(), 'figures', suffix)
    plt.savefig(fname)
    print(f'\nImage saved to: {fname}')
Plot only one thing, similar to the table method.

    Let's not plot transporter-goal-snaive.
    
Plot only one thing, similar to the table method.
Let's not plot transporter-goal-snaive.
Plot only one thing similar to the table method . Let ' s not plot transporter - goal - snaive .
def plot_single(args, goal_conditioned, name_task, name_plot):
    IGNORE = ['-transporter-goal-naive']
    title_size = 40
    x_size = 38
    y_size = 38
    tick_size = 35
    legend_size = 25
    lw = 5
    ms = 12
    nrows, ncols = 1, 4
    fig, ax = plt.subplots(nrows, ncols, squeeze=True, figsize=(8.0*ncols, 9.0*nrows))
    title = f'Training Results, {name_plot}'
    supertitle = fig.suptitle(title, fontsize=title_size+2)
    for col, num_demos in enumerate([1, 10, 100, 1000]):
        directories, seeds = get_subdirectories_demos(name_task, num_demos)
        stats_combo = _get_results(name_task, directories, seeds, debug)
        for agent in sorted(stats_combo.keys()):
            if agent in IGNORE:
                print(f'  ignoring {agent} for demos {num_demos}')
                continue
            x_vals = []
            y_vals = []
            y_errs = []  
            y_stde = []  
            print(f'on agent {agent} with keys {stats_combo[agent].keys()}')
            for itr in sorted(stats_combo[agent].keys()):
                x_vals.append( itr )
                values = stats_combo[agent][itr]
                if (len(values) != 60 and name_task != 'bag-color-goal' and itr != 0):
                    print(f'\tWarning, len(values): {len(values)} for: {agent}, {itr}')
                elif (len(values) != 20 and name_task == 'bag-color-goal'):
                    print(f'\tWarning, len(values): {len(values)} for: {agent}, {itr}')
                y_vals.append( np.mean(values) )
                y_errs.append( np.std(values) )
                y_stde.append( np.std(values) / np.sqrt(len(values)) )
            x_vals = np.array(x_vals)
            y_vals = np.array(y_vals)
            y_errs = np.array(y_errs)
            y_stde = np.array(y_stde)
            x_vals = x_vals / 1000
            ag = agent[1:]
            agent_label = AGENT_TO_LABEL[ag]
            color = AGENT_TO_COLOR[ag]
            if standard_error:
                lower = np.clip(y_vals - y_stde, 0.0 - EPS, 1.0 + EPS)
                upper = np.clip(y_vals + y_stde, 0.0 - EPS, 1.0 + EPS)
            else:
                lower = np.clip(y_vals - y_errs, 0.0 - EPS, 1.0 + EPS)
                upper = np.clip(y_vals + y_errs, 0.0 - EPS, 1.0 + EPS)
            ax[col].plot(x_vals, y_vals, lw=lw, color=color, ms=ms, marker='o', label=agent_label)
            ax[col].fill_between(x_vals, upper, lower, color=color, alpha=0.3, linewidth=0.0)
            ax[col].legend(prop={'size': legend_size})
        subplot_title = f'Train Demos: {num_demos}'
        ax[col].set_title(subplot_title, fontsize=title_size)
        ax[col].set_xlabel(xlabel, fontsize=x_size)
        ylabel = 'Success Rate'
        if not args.binary:
            if name_task in ['cloth-flat', 'cloth-flat-notarget']:
                ylabel = 'Zone Coverage'
            elif name_task in ['cable-shape', 'cable-shape-notarget', 'cable-line-notarget']:
                ylabel = 'Percent in Zone'
        if col == 0:
            ax[col].set_ylabel(ylabel, fontsize=y_size)
        ax[col].set_ylim([0.0 - EPS, 1.0 + EPS])
        ax[col].tick_params(axis='x', labelsize=tick_size)
        ax[col].tick_params(axis='y', labelsize=tick_size)
    plt.tight_layout()
    supertitle.set_y(0.98)
    fig.subplots_adjust(top=0.85)
    suffix = f'plot_demos_task_{name_task}_v02.png'
    fname = join(os.getcwd(), 'figures', suffix)
    plt.savefig(fname)
    print(f'\nImage saved to: {fname}')
def plot_single ( args , goal_conditioned , name_task , name_plot ) : IGNORE = [ '-transporter-goal-naive' ] title_size = 40 x_size = 38 y_size = 38 tick_size = 35 legend_size = 25 lw = 5 ms = 12 nrows , ncols = 1 , 4 fig , ax = plt . subplots ( nrows , ncols , squeeze = True , figsize = ( 8.0 * ncols , 9.0 * nrows ) ) title = f'Training Results, {name_plot}' supertitle = fig . suptitle ( title , fontsize = title_size + 2 ) for col , num_demos in enumerate ( [ 1 , 10 , 100 , 1000 ] ) : directories , seeds = get_subdirectories_demos ( name_task , num_demos ) stats_combo = _get_results ( name_task , directories , seeds , debug ) for agent in sorted ( stats_combo . keys ( ) ) : if agent in IGNORE : print ( f'  ignoring {agent} for demos {num_demos}' ) continue x_vals = [ ] y_vals = [ ] y_errs = [ ] y_stde = [ ] print ( f'on agent {agent} with keys {stats_combo[agent].keys()}' ) for itr in sorted ( stats_combo [ agent ] . keys ( ) ) : x_vals . append ( itr ) values = stats_combo [ agent ] [ itr ] if ( len ( values ) != 60 and name_task != 'bag-color-goal' and itr != 0 ) : print ( f'\tWarning, len(values): {len(values)} for: {agent}, {itr}' ) elif ( len ( values ) != 20 and name_task == 'bag-color-goal' ) : print ( f'\tWarning, len(values): {len(values)} for: {agent}, {itr}' ) y_vals . append ( np . mean ( values ) ) y_errs . append ( np . std ( values ) ) y_stde . append ( np . std ( values ) / np . sqrt ( len ( values ) ) ) x_vals = np . array ( x_vals ) y_vals = np . array ( y_vals ) y_errs = np . array ( y_errs ) y_stde = np . array ( y_stde ) x_vals = x_vals / 1000 ag = agent [ 1 : ] agent_label = AGENT_TO_LABEL [ ag ] color = AGENT_TO_COLOR [ ag ] if standard_error : lower = np . clip ( y_vals - y_stde , 0.0 - EPS , 1.0 + EPS ) upper = np . clip ( y_vals + y_stde , 0.0 - EPS , 1.0 + EPS ) else : lower = np . clip ( y_vals - y_errs , 0.0 - EPS , 1.0 + EPS ) upper = np . clip ( y_vals + y_errs , 0.0 - EPS , 1.0 + EPS ) ax [ col ] . plot ( x_vals , y_vals , lw = lw , color = color , ms = ms , marker = 'o' , label = agent_label ) ax [ col ] . fill_between ( x_vals , upper , lower , color = color , alpha = 0.3 , linewidth = 0.0 ) ax [ col ] . legend ( prop = { 'size' : legend_size } ) subplot_title = f'Train Demos: {num_demos}' ax [ col ] . set_title ( subplot_title , fontsize = title_size ) ax [ col ] . set_xlabel ( xlabel , fontsize = x_size ) ylabel = 'Success Rate' if not args . binary : if name_task in [ 'cloth-flat' , 'cloth-flat-notarget' ] : ylabel = 'Zone Coverage' elif name_task in [ 'cable-shape' , 'cable-shape-notarget' , 'cable-line-notarget' ] : ylabel = 'Percent in Zone' if col == 0 : ax [ col ] . set_ylabel ( ylabel , fontsize = y_size ) ax [ col ] . set_ylim ( [ 0.0 - EPS , 1.0 + EPS ] ) ax [ col ] . tick_params ( axis = 'x' , labelsize = tick_size ) ax [ col ] . tick_params ( axis = 'y' , labelsize = tick_size ) plt . tight_layout ( ) supertitle . set_y ( 0.98 ) fig . subplots_adjust ( top = 0.85 ) suffix = f'plot_demos_task_{name_task}_v02.png' fname = join ( os . getcwd ( ) , 'figures' , suffix ) plt . savefig ( fname ) print ( f'\nImage saved to: {fname}' )
Plot only one thing, similar to the table method.
Plot only one thing similar to the table method .
"""Plot only one thing, similar to the table method.

    Let's not plot transporter-goal-snaive.
    """ # Override any parameters here. # Now make the plot. # Extract all relevant subdirectories, and get results. # For each agent, plot. Iterate through keys of stats_combo[agent] IN ORDER. # standard deviations # standard errors of mean # NOTE: we're dividing by thousands here. # Remove leading dash, and then plot, while clipping stdev's to range. # Bells and whistles. For y-axis label, just put it on the leftmost column. # Shift subplots down due to supertitle. # Save file.
args
goal_conditioned
name_task
name_plot