def draw_trajectory(data_dict, show=True): fig3, ax31 = graph.set_fig(fignum=3, subplot=111, figsize=(16, 10)) for domain_num in range(1, 5): # these are lists of core positions cxmax = data_dict["domain{0}".format(domain_num)]["cxmaxlist"] cymax = data_dict["domain{0}".format(domain_num)]["cymaxlist"] cxmin = data_dict["domain{0}".format(domain_num)]["cxminlist"] cymin = data_dict["domain{0}".format(domain_num)]["cyminlist"] core_positions = [[cxmax, cymax], [cxmin, cymin]] # For plot marker = ['v', '^', 's', 'o'] # makers corresponding to domains fillstyle = ['full', 'none'] # Positive core: fill, Negative core: no fill colors = graph.get_first_n_colors_from_color_cycle(4) for j, core_position in enumerate(core_positions): print core_position cx, cy = core_position[0], core_position[1] ax31.plot(cx, cy, color=colors[domain_num - 1], marker=marker[domain_num - 1], alpha=0.7, fillstyle=fillstyle[j]) graph.setaxes(ax31, 0, imsize[1] * scale, 0, imsize[0] * scale) graph.labelaxes(ax31, 'x [mm]', 'y [mm]') ax31.invert_yaxis() if show: graph.show()
ax23.set_title('Position vs Time (averaged over periods)') ax24.set_title('Position vs Time (averaged over periods)') plot_filename = '/comparison/test_span5p0mm_v400p0mms_freq1Hz__position_data' graph.save(outputdir + plot_filename, verbose=True) v_hdf5 = [x / 6.2 * 5.3 for x in v_hdf5] v_hdf5 = np.roll(v_hdf5, int(len(v_hdf5)*0.236)) time_csv = [x + 0.207 for x in time_csv] vel_csv = [x / 6.2 * 5.3 for x in vel_csv] vel_csv = np.roll(vel_csv, int(len(vel_csv) * 0.237)) fig3, ax31, color_patch3 = graph.errorfill(time_enc_short_v, vel_enc_short_avg, vel_enc_short_std, fignum=3, subplot=211, figsize=(12, 8), label='Encoder output') fig3, ax31 = graph.plot(time_csv, vel_csv, label='Software output', fignum=3, subplot=211, figsize=(12, 8), alpha=0.7) fig3, ax31 = graph.plot(time_hdf5, v_hdf5, label='Hough tracking output', fignum=3, subplot=211, figsize=(12, 8), alpha=0.5) graph.labelaxes(ax31, 'Time (s)', 'Velocity (mm/s)') graph.setaxes(ax31, 0, 1, -480, 150) plt.legend() fig3, ax32, color_patch3 = graph.errorfill(time_enc_short_v, vel_enc_short_avg, vel_enc_short_std, fignum=3, subplot=212, figsize=(12, 8), label='Encoder output') fig3, ax32 = graph.plot(time_csv, vel_csv, label='Software output', fignum=3, subplot=212, figsize=(12, 8), alpha=0.7) fig3, ax32 = graph.plot(time_hdf5, v_hdf5, label='Hough tracking output', fignum=3, subplot=212, figsize=(12, 8), alpha=0.5) graph.setaxes(ax32, 0.25, 0.38, -480, 150) graph.labelaxes(ax32, 'Time (s)', 'Velocity (mm/s)') plt.legend() plot_filename = '/comparison/test_span5p0mm_v400p0mms_freq1Hz__encoder_and_hough' graph.save(outputdir + plot_filename, verbose=True) graph.show()