def graph_individual_intersections(labels, colours, fp, metrics, save_dir): #rows are metrics #columns are intersections tsc = os.listdir(fp) tsc.remove('sotl') intersections = os.listdir(fp + tsc[0] + '/' + metrics[0] + '/') ncols = len(intersections) nrows = len(metrics) f, ax = plt.subplots(nrows=nrows, ncols=ncols) if ax.ndim == 1: ax = ax[..., np.newaxis] for m, r in zip(metrics, range(nrows)): #get metric data for each intersection data = {} for t in tsc: data[t] = {} for i in intersections: alias_p = 60 data[t][i] = alias( stack_folder_files(fp + '/' + t + '/' + m + '/' + i + '/'), alias_p) xtitle = 'Time ' + r" $(min)$" if r == nrows - 1 else '' #graph same metric for each intersection for I, c in zip(intersections, range(ncols)): title = I if r == 0 else '' if m == 'queue': ytitle = m.capitalize() + r" $(veh)$" if c == 0 else '' else: ytitle = m.capitalize() + r" $(s)$" if c == 0 else '' legend = (0.59, 0.6) data_order = sorted(data.keys()) alias_p = 60 order_data = [data[d][I] for d in data_order] order_labels = [labels[d] for d in data_order] order_colors = [colours[d] for d in data_order] label_c = {labels[d]: colours[d] for d in data_order} graph(ax[r, c], order_data, multi_line_with_CI(ax[r, c], order_data, order_colors, order_labels), xtitle=xtitle, ytitle_pad=(ytitle, 60), title=title, legend=legend, colours=label_c, grid=True) ax[r, c].set_xlim(left=0) ax[r, c].set_ylim(bottom=0) f.suptitle('Intersection Measures of Effectiveness') save_graph(f, save_dir + 'intersection_moe.pdf', 600, 14, 24.9) plt.show()
def graph_conf_interval(labels, colours, fp, metric): #read metric data for all tsc types data = get_data(fp, metric, get_metric_data) #prepare data for graph data_order = sorted(data.keys()) data = [ data[d] for d in data_order] labels = [ labels[d] for d in data_order] #graph data f, ax = plt.subplots(1,1) metric_title = metric.capitalize() graph( ax, data, multi_line_with_CI( ax, data, colours, labels), xtitle='Time (s)', ytitle_pad = (metric_title, 60), title=metric_title+' by\nTraffic Signal Controller', legend=(0.72, 0.72), grid=True) #f.suptitle(metric_title) #display graph plt.show()