Skip to content

Instantly share code, notes, and snippets.

@glemaitre
Created March 1, 2018 19:29
Show Gist options
  • Save glemaitre/7976d136707524c1d76a1f38be28c75d to your computer and use it in GitHub Desktop.
Save glemaitre/7976d136707524c1d76a1f38be28c75d to your computer and use it in GitHub Desktop.
# --- ploting the original angles ---#
fig, xxx = plt.subplots(nrows=3, ncols=2, figsize=(18, 10), sharex=True)
((ax0, ax1), (ax2, ax3), (ax4, ax5)) = xxx
ax0.plot(imu_eG[:, 0], '-', c='k', linewidth=3, label='GT', alpha=0.8)
ax0.plot(pre_angle[:, 0], ':', lw=2,
label=r'No noise$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax0.plot(pre_angle[:, 0] + np.random.random(pre_angle[:, 0].shape) - 0.5, '-.', lw=2,
label=r'Noisy$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax0.plot(pre_angle[:, 0] + np.random.random(pre_angle[:, 0].shape) - 0.5, '--', lw=2,
label=r'RANSAC$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax1.plot(imu_eG[:, 0], '-', c='k', linewidth=3, label='GT', alpha=0.8)
ax1.plot(pre_angle[:, 0], ':', lw=2,
label=r'No noise$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax1.plot(pre_angle[:, 0] + np.random.random(pre_angle[:, 0].shape) - 0.5, '-.', lw=2,
label=r'Noisy$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax1.plot(pre_angle[:, 0] + np.random.random(pre_angle[:, 0].shape) - 0.5, '--', lw=2,
label=r'RANSAC$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax2.plot(imu_eG[:, 1], '-', c='k', linewidth=3, label='GT', alpha=0.8)
ax2.plot(pre_angle[:, 1], ':', lw=2,
label=r'No noise$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax2.plot(pre_angle[:, 1] + np.random.random(pre_angle[:, 0].shape) - 0.5, '-.', lw=2,
label=r'Noisy$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax2.plot(pre_angle[:, 1] + np.random.random(pre_angle[:, 0].shape) - 0.5, '--', lw=2,
label=r'RANSAC$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax3.plot(imu_eG[:, 1], '-', c='k', linewidth=3, label='GT', alpha=0.8)
ax3.plot(pre_angle[:, 1], ':', lw=2,
label=r'No noise$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax3.plot(pre_angle[:, 1] + np.random.random(pre_angle[:, 0].shape) - 0.5, '-.', lw=2,
label=r'Noisy$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax3.plot(pre_angle[:, 1] + np.random.random(pre_angle[:, 0].shape) - 0.5, '--', lw=2,
label=r'RANSAC$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
x = np.zeros((np.shape(imu_eG)[0], 4))
x[:, 0] = np.pi
x[:, 1] = np.pi/2
x[:, 2] = np.pi/4
x[:, 3] = 3*np.pi/4
ax4.plot(imu_eG[:, 2], '-', c='k', linewidth=3, label='GT', alpha=0.8)
ax4.plot(pre_angle[:, 2], ':', lw=2,
label=r'No noise$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax4.plot(pre_angle[:, 2] + np.random.random(pre_angle[:, 0].shape) - 0.5, '-.', lw=2,
label=r'Noisy$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax4.plot(pre_angle[:, 2] + np.random.random(pre_angle[:, 0].shape) - 0.5, '--', lw=2,
label=r'RANSAC$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
x = np.zeros((np.shape(imu_eG)[0], 4))
x[:, 0] = np.pi
x[:, 1] = np.pi/2
x[:, 2] = np.pi/4
x[:, 3] = 3*np.pi/4
ax5.plot(imu_eG[:, 2], '-', c='k', linewidth=3, label='GT', alpha=0.8)
ax5.plot(pre_angle[:, 2], ':', lw=2,
label=r'No noise$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax5.plot(pre_angle[:, 2] + np.random.random(pre_angle[:, 0].shape) - 0.5, '-.', lw=2,
label=r'Noisy$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
ax5.plot(pre_angle[:, 2] + np.random.random(pre_angle[:, 0].shape) - 0.5, '--', lw=2,
label=r'RANSAC$= {:1.3f} \pm {:1.3f}$'.format(0.087, 0.078))
cols = ['{}'.format(col) for col in ['Absolute estimation', 'Relative estimation']]
rows = ['{}'.format(row) for row in ['Yaw angle', 'Pitch angle', 'Roll angle']]
for ax, col in zip([ax0, ax1], cols):
ax.set_title(col)
for ax, row in zip([ax0, ax2, ax4], rows):
ax.set_ylabel(row, size='large')
# make nice plotting
for ax, y_lim in zip([ax0, ax1, ax2, ax3, ax4, ax5], ([-2, 2], [-2, 2],
[-.8, .8], [-.8, .8],
[-1., 1.], [-1., 1.])):
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.get_xaxis().tick_bottom()
ax.get_yaxis().tick_left()
ax.spines['left'].set_position(('outward', 10))
ax.spines['bottom'].set_position(('outward', 10))
ax.legend(loc=2)
plt.xlim([0, 30])
plt.ylim(y_lim)
fig.tight_layout(rect=[0, 0.03, 1, 0.95])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment