From 6b0d87ff7e64c7cb0bb3a6ffc0dfa6d30cfebecf Mon Sep 17 00:00:00 2001 From: mahdinobar Date: Fri, 10 May 2024 12:03:59 +0200 Subject: [PATCH] plot for paper for run Fepv0_15_lr0001_5000epochs_lp130_separated_pose_errors_qinitnoisy added, #2 --- .../gym/envs/classic_control/fep.py | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/spinup/backup_gym/gym/envs/classic_control/fep.py b/spinup/backup_gym/gym/envs/classic_control/fep.py index d0cb06c90..ef203349e 100644 --- a/spinup/backup_gym/gym/envs/classic_control/fep.py +++ b/spinup/backup_gym/gym/envs/classic_control/fep.py @@ -530,6 +530,30 @@ def render(self, output_dir_rendering, mode='human'): plt.savefig(output_dir_rendering + "/position.pdf", format="pdf", bbox_inches='tight') plt.show() + fig1, axs1 = plt.subplots(3, 1, sharex=False, sharey=False, figsize=(6, 8)) + plt.rcParams['font.family'] = 'Serif' + axs1[0].plot(self.plot_data_buffer[:, 3] * 1000, self.plot_data_buffer[:, 4] * 1000, 'k--', + label='EE desired traj') + axs1[0].plot(self.plot_data_buffer[:, 0] * 1000, self.plot_data_buffer[:, 1] * 1000, 'r') + axs1[0].plot(plot_data_buffer_no_SAC[:, 0] * 1000, plot_data_buffer_no_SAC[:, 1] * 1000, 'b') + axs1[0].set_xlabel("x[mm]") + axs1[0].set_ylabel("y[mm]") + axs1[1].plot(self.plot_data_buffer[:, 3] * 1000, self.plot_data_buffer[:, 5] * 1000, 'k--', + label='EE desired traj') + axs1[1].plot(self.plot_data_buffer[:, 0] * 1000, self.plot_data_buffer[:, 2] * 1000, 'r') + axs1[1].plot(plot_data_buffer_no_SAC[:, 0] * 1000, plot_data_buffer_no_SAC[:, 2] * 1000, 'b') + axs1[1].set_xlabel("x[mm]") + axs1[1].set_ylabel("z[mm]") + axs1[2].plot(self.plot_data_buffer[:, 4] * 1000, self.plot_data_buffer[:, 5] * 1000, 'k--', + label='EE desired traj') + axs1[2].plot(self.plot_data_buffer[:, 1] * 1000, self.plot_data_buffer[:, 2] * 1000, 'r',label='with SAC') + axs1[2].plot(plot_data_buffer_no_SAC[:, 1] * 1000, plot_data_buffer_no_SAC[:, 2] * 1000, 'b',label='without SAC') + axs1[2].set_xlabel("y[mm]") + axs1[2].set_ylabel("z[mm]") + plt.legend() + plt.savefig(output_dir_rendering + "/position_both.pdf", format="pdf", bbox_inches='tight') + plt.show() + fig2, axs2 = plt.subplots(3, 1, sharex=False, sharey=False, figsize=(7, 14)) axs2[0].plot(self.plot_data_buffer[:, 9], self.plot_data_buffer[:, 10], 'r--', label='EE desired traj', marker=".", @@ -582,6 +606,7 @@ def render(self, output_dir_rendering, mode='human'): plt.show() fig3, axs3 = plt.subplots(4, 1, sharex=False, sharey=False, figsize=(6, 8)) + plt.rcParams['font.family'] = 'Serif' axs3[0].plot(abs(plot_data_buffer_no_SAC[:, 0] - plot_data_buffer_no_SAC[:, 3]) * 1000, 'b', label='without SAC') axs3[0].plot(abs(self.plot_data_buffer[:, 0] - self.plot_data_buffer[:, 3]) * 1000, 'r', label='with SAC') @@ -611,7 +636,7 @@ def render(self, output_dir_rendering, mode='human'): # axs3[3].set_ylim([0, 10]) # axs3[3].set_yscale('log') plt.legend() - plt.savefig(output_dir_rendering + "/position_errors.pdf", format="pdf", bbox_inches='tight') + plt.savefig(output_dir_rendering + "/position_errors_both.pdf", format="pdf", bbox_inches='tight') plt.show() fig4, axs4 = plt.subplots(3, 2, sharex=False, sharey=False, figsize=(8, 6))