From 1ae288659e298421a7a27ec584c59869c7ad764a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?K=C3=BChle=2C=20Laura=20Christine=20=28lakue103=29?=
 <laura.kuehle@uni-duesseldorf.de>
Date: Tue, 1 Mar 2022 16:58:21 +0100
Subject: [PATCH] Improved legend layout for model evaluation plots.

---
 Plotting.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Plotting.py b/Plotting.py
index 2059f88..7afc200 100644
--- a/Plotting.py
+++ b/Plotting.py
@@ -279,7 +279,7 @@ def plot_classification_accuracy(evaluation_dict: dict, colors: dict) -> None:
     pos = np.arange(len(model_names))
     width = 1/(3*len(model_names))
     fig = plt.figure('classification_accuracy')
-    ax = fig.add_axes([0.15, 0.3, 0.75, 0.6])
+    ax = fig.add_axes([0.15, 0.3, 0.6, 0.6])
     step_len = 1
     adjustment = -(len(model_names)//2)*step_len
     for measure in evaluation_dict:
@@ -295,7 +295,8 @@ def plot_classification_accuracy(evaluation_dict: dict, colors: dict) -> None:
     ax.set_ylim(bottom=-0.02)
     ax.set_ylim(top=1.02)
     ax.set_title('Classification Evaluation (Barplot)')
-    ax.legend(loc='upper right')
+    ax.legend(loc='center right', bbox_to_anchor=(1.4, 0.75), shadow=True,
+              ncol=1, fancybox=True, fontsize=8)
 
 
 def plot_boxplot(evaluation_dict: dict, colors: dict) -> None:
@@ -314,7 +315,7 @@ def plot_boxplot(evaluation_dict: dict, colors: dict) -> None:
     model_names = evaluation_dict[list(colors.keys())[0]].keys()
     font_size = 16 - (len(max(model_names, key=len))//3)
     fig = plt.figure('boxplot_accuracy')
-    ax = fig.add_axes([0.15, 0.3, 0.75, 0.6])
+    ax = fig.add_axes([0.15, 0.3, 0.6, 0.6])
     step_len = 1.5
     boxplots = []
     adjustment = -(len(model_names)//2)*step_len
@@ -339,4 +340,5 @@ def plot_boxplot(evaluation_dict: dict, colors: dict) -> None:
     ax.set_ylabel('Classification (%)')
     ax.set_title('Classification Evaluation (Boxplot)')
     ax.legend([bp["boxes"][0] for bp in boxplots], evaluation_dict.keys(),
-              loc='upper right')
+              loc='center right', bbox_to_anchor=(1.4, 0.75), shadow=True,
+              ncol=1, fancybox=True, fontsize=8)
-- 
GitLab