def plot_flow_rate_v2_road_length(): """Convenice function used to plot the data gathered for the road_length test""" style.use('bmh') data1_road = load_flow_data(road_length=500, n_iterations=10000, vmax=5) data2_road = load_flow_data(road_length=200, n_iterations=10000, vmax=5) data3_road = load_flow_data(road_length=100, n_iterations=10000, vmax=5) data4_road = load_flow_data(road_length=50, n_iterations=10000, vmax=5) fig, ax = plt.subplots() ax.plot(data1_road[:, 0], data1_road[:, 1], lw=1, c='r', label='500') ax.plot(data2_road[:, 0], data2_road[:, 1], lw=1, c='b', label='200') ax.plot(data3_road[:, 0], data3_road[:, 1], lw=1, c='limegreen', label='100') ax.plot(data4_road[:, 0], data4_road[:, 1], lw=1, c='black', label='50') ax.set_xlim(0, 0.8) ax.set_ylim(0, 1) ax.set_ylabel(r'$Flow \ Rate \ \frac{passes}{iteration}$', labelpad=10, fontsize=30) ax.set_xlabel(r'$Density \ \frac{cars}{sites}$', labelpad=10, fontsize=30) from mpl_toolkits.axes_grid1.inset_locator import zoomed_inset_axes, mark_inset # zoom-factor: 2.5, location: upper-left axins = zoomed_inset_axes(ax, 2.5, loc='upper right') axins.plot(data1_road[:, 0], data1_road[:, 1], lw=1, c='r', label='500') axins.plot(data2_road[:, 0], data2_road[:, 1], lw=1, c='b', label='200') axins.plot(data3_road[:, 0], data3_road[:, 1], lw=1, c='limegreen', label='100') axins.plot(data4_road[:, 0], data4_road[:, 1], lw=1, c='black', label='50') x1, x2, y1, y2 = 0.1, 0.25, 0.6, 0.8 # specify the limits axins.set_xlim(x1, x2) # apply the x-limits axins.set_ylim(y1, y2) axins.legend(loc='upper right', prop={'size': 20}) ax.minorticks_on() axins.minorticks_on() mark_inset(ax, axins, loc1=2, loc2=4, fc="none", ec="0.5") # # plt.show()
def plot_2d_flow(): data1 = load_flow_data(road_length=500, n_iterations=10000, vmax=5) data2 = pf.load_flow_data(road_length=500, n_iterations=10000, vmax=5) font = { 'family': 'serif', 'color': 'black', 'weight': 'normal', 'size': 15 } style.use('bmh') fig, ax = plt.subplots() ax.plot(data1[:, 0], data1[:, 1], lw=1, c='r', label='Double Lane') ax.plot(data2[:, 0], data2[:, 1], lw=1, c='b', label='Single Lane') ax.legend(loc='upper right', prop={'size': 15}) ax.minorticks_on() ax.set_ylabel(r'$Flow \ Rate \ \frac{Passes}{Iteration}$', labelpad=10, fontdict=font) ax.set_xlabel(r'$Density \ \frac{Cars}{Sites}$', labelpad=10, fontdict=font) plt.show()
def plot_flow_rate_v2_proba(): """Convenice function used to plot the data gathered for the probability test""" style.use('bmh') data1_road = load_flow_data(road_length=500, n_iterations=9995, vmax=5, type='proba') data2_road = load_flow_data(road_length=500, n_iterations=10000, vmax=5) data3_road = load_flow_data(road_length=500, n_iterations=9998, vmax=5, type='proba') data4_road = load_flow_data(road_length=500, n_iterations=9997, vmax=5, type='proba') fig, ax = plt.subplots() ax.plot(data1_road[:, 0], data1_road[:, 1], lw=1, c='r', label='0.05') ax.plot(data2_road[:, 0], data2_road[:, 1], lw=1, c='b', label='0.1') ax.plot(data3_road[:, 0], data3_road[:, 1], lw=1, c='limegreen', label='0.2') ax.plot(data4_road[:, 0], data4_road[:, 1], lw=1, c='black', label='0.3') ax.set_xlim(0, 0.8) ax.set_ylim(0, 1) ax.set_ylabel(r'$Flow \ Rate \ \frac{passes}{iteration}$', labelpad=10, fontsize=30) ax.set_xlabel(r'$Density \ \frac{cars}{sites}$', labelpad=10, fontsize=30) ax.legend(loc='upper right', prop={'size': 20}) ax.minorticks_on() plt.show()
def plot_flow_rate_v2_profiles(): style.use('bmh') data_perfect = load_flow_data(road_length=500, n_iterations=10000, vmax=15) data1 = load_flow_data(road_length=500, n_iterations=10000, vmax=15, type='profiles', profile='0.2') data2 = load_flow_data(road_length=500, n_iterations=10000, vmax=15, type='profiles', profile='0.3') data3 = load_flow_data(road_length=500, n_iterations=10000, vmax=15, type='profiles', profile='0.5') fig, ax = plt.subplots() ax.plot(data_perfect[:, 0], data_perfect[:, 1], c='r', label='Perfect', lw=1) ax.plot(data1[:, 0], data1[:, 1], c='black', label='Profile 1', lw=1) ax.plot(data2[:, 0], data2[:, 1], c='limegreen', label='Profile 2', lw=1) ax.plot(data3[:, 0], data3[:, 1], c='b', label='Profile 3', lw=1) ax.legend(loc='upper right', prop={'size': 20}) ax.set_ylabel(r'$Flow \ Rate \ \frac{passes}{iteration}$', labelpad=10, fontsize=30) ax.set_xlabel(r'$Density \ \frac{cars}{sites}$', labelpad=10, fontsize=30) ax.minorticks_on() plt.show()