I have the following code:
figure, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2,2, figsize=(8.33, 3.5), dpi=250, layout="constrained")
figure.suptitle("Start of real vs. DGAN generated scaled trajectory of route 3", fontsize=10)
figure.supxlabel("First 2000 sample points", fontsize=9)
ax1.plot(df_train_new_rol_mean[df_train_new_rol_mean.log_index == choice(valid_log_indexes)][movement_columns].values[samples], linewidth=0.85)
ax1.set_ylabel("Motion data", fontsize=8)
ax1.set_title("Real motion", fontsize=8)
ax2.plot(df_synth_rol_mean[df_synth_rol_mean.log_index == randint(0, 49)][movement_columns].values[samples], linewidth=0.85)
ax2.set_title("Synthetic motion", fontsize=8)
ax1.sharey(ax2)
ax2.legend(movement_columns, loc='upper center',
ncol=3, fancybox=True, shadow=True)
ax3.plot(le.transform(df_train_new_rol_mean["Locations"])[samples])
ax3.set_ylabel("Locations encoded", fontsize=8)
ax3.set_title("Real encoding", fontsize=8)
ax4.plot(le.transform(df_synth_rol_mean["Locations"])[samples])
ax4.set_title("Synthetic encoding", fontsize=8)
ax3.sharey(ax4)
You see that the legend is really large and covers the actual plot. What would be the best option in general if such problem occurs? Can I just detach the legend and display it on top of the figure?