Exemplo n.º 1
0
def plot_opening(csv_data):
    keys = ['distance', 'type', 'repetition']
    llists = expand(extract_keys(csv_data, keys), keys)
    dists = np.array([float(f) for f in llists[0]]) / 100.
    types = llists[1]

    types_arr = np.array(types)
    drawer_dists = dists[np.where(types_arr == 'R')[0]]
    other_dists = dists[np.where(types_arr != 'R')[0]]

    print 'Opening distances types', set(types)
    bin_width = 0.02
    bins = np.arange(-bin_width / 2., np.max(dists) + 2 * bin_width, bin_width)
    dists_list = [dists]  #, drawer_dists, other_dists]
    titles = ['Opening Distances of Drawers']  #, 'drawer', 'other']

    #    print 'Total number of drawers:', len(dists)
    mpu.set_figure_size(5., 4.)
    for idx, d in enumerate(dists_list):
        f = pb.figure()
        f.set_facecolor('w')
        hist, bin_edges = np.histogram(d, bins)
        #import pdb; pdb.set_trace()
        mpu.plot_histogram(bin_edges[:-1] + bin_width / 2.,
                           hist,
                           width=0.8 * bin_width,
                           xlabel='Opening Distance (meters)',
                           ylabel='\# of Mechanisms',
                           plot_title=titles[idx],
                           color='#3366FF')
Exemplo n.º 2
0
def plot_opening(csv_data):
    keys = ['distance', 'type', 'repetition']
    llists = expand(extract_keys(csv_data, keys), keys)
    dists = np.array([float(f) for f in llists[0]])/100.
    types = llists[1]

    types_arr = np.array(types)
    drawer_dists = dists[np.where(types_arr == 'R')[0]]
    other_dists = dists[np.where(types_arr != 'R')[0]]

    print 'Opening distances types', set(types)
    bin_width = 0.02
    bins = np.arange(-bin_width/2., np.max(dists)+2*bin_width, bin_width)
    dists_list = [dists]#, drawer_dists, other_dists]
    titles = ['Opening Distances of Drawers']#, 'drawer', 'other']

#    print 'Total number of drawers:', len(dists)
    mpu.set_figure_size(5.,4.)
    for idx, d in enumerate(dists_list):
        f = pb.figure()
        f.set_facecolor('w')
        hist, bin_edges = np.histogram(d, bins)
        #import pdb; pdb.set_trace()
        mpu.plot_histogram(bin_edges[:-1]+bin_width/2., hist,
                           width=0.8*bin_width, xlabel='Opening Distance (meters)',
                           ylabel='\# of Mechanisms',
                           plot_title=titles[idx], color='#3366FF')
Exemplo n.º 3
0
def plot_err_histogram(rel_list, abs_list, title):
    # plot relative error histogram.
    max_err = 1.0
    bin_width = 0.05  # relative err.
    bins = np.arange(0. - bin_width / 2. - max_err, max_err + 2 * bin_width,
                     bin_width)
    hist, bin_edges = np.histogram(np.array(rel_list), bins)
    mpu.figure()
    mpu.plot_histogram(bin_edges[:-1] + bin_width / 2.,
                       hist,
                       width=bin_width * 0.8,
                       xlabel='Relative Error',
                       plot_title=title)
    # plot relative error histogram.
    max_err = 20
    bin_width = 2  # relative err.
    bins = np.arange(0. - bin_width / 2. - max_err, max_err + 2 * bin_width,
                     bin_width)
    hist, bin_edges = np.histogram(np.array(abs_list), bins)
    mpu.figure()
    mpu.plot_histogram(bin_edges[:-1] + bin_width / 2.,
                       hist,
                       width=bin_width * 0.8,
                       xlabel='Absolute Error',
                       plot_title=title)
Exemplo n.º 4
0
def handle_height_histogram(mean_height_list, plot_title='', color='#3366FF', max_height=2.5, bin_width=.1, ymax=35):
    bins = np.arange(0.-bin_width/2., max_height+2*bin_width, bin_width)
    hist, bin_edges = np.histogram(np.array(mean_height_list), bins)
    f = pb.figure()
    f.set_facecolor('w')
    f.subplots_adjust(bottom=.16, top=.86)
    mpu.plot_histogram(bin_edges[:-1]+bin_width/2., hist,
                       width=bin_width*0.8, plot_title=plot_title,
                       xlabel='Height (meters)', ylabel='\# of mechanisms', color=color)
    pb.xlim(0, max_height)
    pb.ylim(0, ymax)
Exemplo n.º 5
0
def handle_height_histogram_advait(mean_height_list,
                                   plot_title='',
                                   color='#3366FF',
                                   max_height=2.2,
                                   bin_width=.1,
                                   ymax=35,
                                   new_figure=True,
                                   label='__no_legend__'):
    if new_figure:
        mpu.set_figure_size(5., 4.)


#        f = mpu.figure()
#        f.subplots_adjust(bottom=.25, top=.99, right=0.99, left=0.12)
    bins = np.arange(0. - bin_width / 2., max_height + 2 * bin_width,
                     bin_width)
    hist, bin_edges = np.histogram(np.array(mean_height_list), bins)
    h = mpu.plot_histogram(bin_edges[:-1] + bin_width / 2.,
                           hist,
                           width=bin_width * 0.8,
                           plot_title=plot_title,
                           xlabel='Height (meters)',
                           ylabel='\# of mechanisms',
                           color=color,
                           label=label)
    pb.xlim(0, max_height)
    pb.ylim(0, ymax)
    return h
Exemplo n.º 6
0
def plot_err_histogram(rel_list, abs_list, title):
    # plot relative error histogram.
    max_err = 1.0
    bin_width = 0.05 # relative err.
    bins = np.arange(0.-bin_width/2.-max_err, max_err+2*bin_width, bin_width)
    hist, bin_edges = np.histogram(np.array(rel_list), bins)
    mpu.figure()
    mpu.plot_histogram(bin_edges[:-1]+bin_width/2., hist,
                       width=bin_width*0.8, xlabel='Relative Error',
                       plot_title=title)
    # plot relative error histogram.
    max_err = 20
    bin_width = 2 # relative err.
    bins = np.arange(0.-bin_width/2.-max_err, max_err+2*bin_width, bin_width)
    hist, bin_edges = np.histogram(np.array(abs_list), bins)
    mpu.figure()
    mpu.plot_histogram(bin_edges[:-1]+bin_width/2., hist,
                       width=bin_width*0.8, xlabel='Absolute Error',
                       plot_title=title)
Exemplo n.º 7
0
def handle_height_histogram(mean_height_list,
                            plot_title='',
                            color='#3366FF',
                            max_height=2.5,
                            bin_width=.1,
                            ymax=35):
    bins = np.arange(0. - bin_width / 2., max_height + 2 * bin_width,
                     bin_width)
    hist, bin_edges = np.histogram(np.array(mean_height_list), bins)
    f = pb.figure()
    f.set_facecolor('w')
    f.subplots_adjust(bottom=.16, top=.86)
    mpu.plot_histogram(bin_edges[:-1] + bin_width / 2.,
                       hist,
                       width=bin_width * 0.8,
                       plot_title=plot_title,
                       xlabel='Height (meters)',
                       ylabel='\# of mechanisms',
                       color=color)
    pb.xlim(0, max_height)
    pb.ylim(0, ymax)
Exemplo n.º 8
0
def handle_height_histogram_advait(mean_height_list, plot_title='',
                                   color='#3366FF', max_height=2.2, bin_width=.1, ymax=35,
                                   new_figure = True, label = '__no_legend__'):
    if new_figure:
        mpu.set_figure_size(5.,4.)
#        f = mpu.figure()
#        f.subplots_adjust(bottom=.25, top=.99, right=0.99, left=0.12)
    bins = np.arange(0.-bin_width/2., max_height+2*bin_width, bin_width)
    hist, bin_edges = np.histogram(np.array(mean_height_list), bins)
    h = mpu.plot_histogram(bin_edges[:-1]+bin_width/2., hist,
                           width=bin_width*0.8, plot_title=plot_title,
                           xlabel='Height (meters)', ylabel='\# of mechanisms', color=color, label = label)
    pb.xlim(0, max_height)
    pb.ylim(0, ymax)
    return h
Exemplo n.º 9
0
def plot_radii(csv_data, color='#3366FF'):
    keys = ['radius', 'type', 'name', 'repetition']
    llists = expand(extract_keys(csv_data, keys), keys)
    rad_list = np.array([float(r) for r in llists[0]]) / 100.0
    types = llists[1]
    names = np.array(llists[2])
    all_types = set(types)
    print 'Radii types', all_types

    types_arr = np.array(types)
    # np.where(types_arr == 'C')
    cabinet_rad_list = rad_list[np.where(types_arr == 'C')[0]]
    others_rad_list = rad_list[np.where(types_arr != 'C')[0]]
    other_names = names[np.where(types_arr != 'C')[0]]
    print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
    print 'radii other names'
    for i, n in enumerate(other_names):
        print n, others_rad_list[i]
    print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'

    rad_lists = [rad_list, cabinet_rad_list, others_rad_list]
    titles = ['Radii of Rotary Mechanisms', 'Radii of Cabinets', 'Radii of Other Mechanisms']
    bin_width = 0.05
    max_radius = np.max(rad_list)
    print 'MIN RADIUS', np.min(rad_list)
    print 'MAX RADIUS', max_radius

    mpu.set_figure_size(5.,5.)
    for idx, radii in enumerate(rad_lists):
        f = pb.figure()
        f.set_facecolor('w')
        bins = np.arange(0.-bin_width/2., max_radius+2*bin_width, bin_width)
        hist, bin_edges = np.histogram(radii, bins)
        h = mpu.plot_histogram(bin_edges[:-1]+bin_width/2., hist,
                           width=0.8*bin_width, xlabel='Radius (meters)',
                           ylabel='\# of mechanisms',
                           plot_title=titles[idx],
                           color=color, label='All')
        pb.xlim(.1, 1.)
        pb.ylim(0, 55)
        mpu.legend(display_mode = 'less_space', handlelength=1.)

    #-- different classes in different colors in the same histogram.
    f = pb.figure()
    f.set_facecolor('w')
    bins = np.arange(0.-bin_width/2., max_radius+2*bin_width, bin_width)
    hist, bin_edges = np.histogram(rad_lists[0], bins)
    h = mpu.plot_histogram(bin_edges[:-1]+bin_width/2., hist,
                       width=0.8*bin_width, xlabel='Radius (meters)',
                       ylabel='\# of mechanisms',
                       plot_title=titles[1],
                       color='g', label='Cabinets')
    hist, bin_edges = np.histogram(rad_lists[2], bins)
    h = mpu.plot_histogram(bin_edges[:-1]+bin_width/2., hist,
                       width=0.8*bin_width, xlabel='Radius (meters)',
                       ylabel='\# of mechanisms',
                       plot_title='Cabinets and Other Mechanisms',
                       color='y', label='Other')
    pb.xlim(.1, 1.)
    pb.ylim(0, 55)
    mpu.legend(display_mode = 'less_space', handlelength=1.)

    color_list = ['g', 'b', 'r']
    marker_list = ['s', '^', 'v']
    label_list = ['All', 'Cabinets', 'Other']
    scatter_size_list = [8, 5, 5]
    mpu.set_figure_size(5.,5.)
    mpu.figure()
    for idx, radii in enumerate(rad_lists):
        bins = np.arange(0.-bin_width/2., max_radius+2*bin_width, bin_width)
        hist, bin_edges = np.histogram(radii, bins)
        bin_midpoints = np.arange(0., max_radius+bin_width, bin_width)
        mpu.plot_yx(hist, bin_midpoints, color = color_list[idx],
                    alpha = 0.6, marker = marker_list[idx],
                    scatter_size = scatter_size_list[idx], xlabel='Radius (meters)',
                    ylabel='\# of mechanisms', label = label_list[idx])
    mpu.legend(display_mode = 'less_space')
Exemplo n.º 10
0
def plot_radii(csv_data, color='#3366FF'):
    keys = ['radius', 'type', 'name', 'repetition']
    llists = expand(extract_keys(csv_data, keys), keys)
    rad_list = np.array([float(r) for r in llists[0]]) / 100.0
    types = llists[1]
    names = np.array(llists[2])
    all_types = set(types)
    print 'Radii types', all_types

    types_arr = np.array(types)
    # np.where(types_arr == 'C')
    cabinet_rad_list = rad_list[np.where(types_arr == 'C')[0]]
    others_rad_list = rad_list[np.where(types_arr != 'C')[0]]
    other_names = names[np.where(types_arr != 'C')[0]]
    print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
    print 'radii other names'
    for i, n in enumerate(other_names):
        print n, others_rad_list[i]
    print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'

    rad_lists = [rad_list, cabinet_rad_list, others_rad_list]
    titles = [
        'Radii of Rotary Mechanisms', 'Radii of Cabinets',
        'Radii of Other Mechanisms'
    ]
    bin_width = 0.05
    max_radius = np.max(rad_list)
    print 'MIN RADIUS', np.min(rad_list)
    print 'MAX RADIUS', max_radius

    mpu.set_figure_size(5., 5.)
    for idx, radii in enumerate(rad_lists):
        f = pb.figure()
        f.set_facecolor('w')
        bins = np.arange(0. - bin_width / 2., max_radius + 2 * bin_width,
                         bin_width)
        hist, bin_edges = np.histogram(radii, bins)
        h = mpu.plot_histogram(bin_edges[:-1] + bin_width / 2.,
                               hist,
                               width=0.8 * bin_width,
                               xlabel='Radius (meters)',
                               ylabel='\# of mechanisms',
                               plot_title=titles[idx],
                               color=color,
                               label='All')
        pb.xlim(.1, 1.)
        pb.ylim(0, 55)
        mpu.legend(display_mode='less_space', handlelength=1.)

    #-- different classes in different colors in the same histogram.
    f = pb.figure()
    f.set_facecolor('w')
    bins = np.arange(0. - bin_width / 2., max_radius + 2 * bin_width,
                     bin_width)
    hist, bin_edges = np.histogram(rad_lists[0], bins)
    h = mpu.plot_histogram(bin_edges[:-1] + bin_width / 2.,
                           hist,
                           width=0.8 * bin_width,
                           xlabel='Radius (meters)',
                           ylabel='\# of mechanisms',
                           plot_title=titles[1],
                           color='g',
                           label='Cabinets')
    hist, bin_edges = np.histogram(rad_lists[2], bins)
    h = mpu.plot_histogram(bin_edges[:-1] + bin_width / 2.,
                           hist,
                           width=0.8 * bin_width,
                           xlabel='Radius (meters)',
                           ylabel='\# of mechanisms',
                           plot_title='Cabinets and Other Mechanisms',
                           color='y',
                           label='Other')
    pb.xlim(.1, 1.)
    pb.ylim(0, 55)
    mpu.legend(display_mode='less_space', handlelength=1.)

    color_list = ['g', 'b', 'r']
    marker_list = ['s', '^', 'v']
    label_list = ['All', 'Cabinets', 'Other']
    scatter_size_list = [8, 5, 5]
    mpu.set_figure_size(5., 5.)
    mpu.figure()
    for idx, radii in enumerate(rad_lists):
        bins = np.arange(0. - bin_width / 2., max_radius + 2 * bin_width,
                         bin_width)
        hist, bin_edges = np.histogram(radii, bins)
        bin_midpoints = np.arange(0., max_radius + bin_width, bin_width)
        mpu.plot_yx(hist,
                    bin_midpoints,
                    color=color_list[idx],
                    alpha=0.6,
                    marker=marker_list[idx],
                    scatter_size=scatter_size_list[idx],
                    xlabel='Radius (meters)',
                    ylabel='\# of mechanisms',
                    label=label_list[idx])
    mpu.legend(display_mode='less_space')