From ef5cae6087ae829b01411c0146c618def6f0dcf2 Mon Sep 17 00:00:00 2001
From: "Daniel.Frisinghelli" <daniel.frisinghelli@eurac.edu>
Date: Thu, 13 Aug 2020 16:35:53 +0200
Subject: [PATCH] Fixed plot order in plot_loss; increased flexibility for
 plot_confusion_matrix

---
 pysegcnn/core/graphics.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/pysegcnn/core/graphics.py b/pysegcnn/core/graphics.py
index 23a8e9b..d164c49 100644
--- a/pysegcnn/core/graphics.py
+++ b/pysegcnn/core/graphics.py
@@ -173,8 +173,7 @@ def plot_confusion_matrix(cm, labels, normalize=True,
     # save figure
     if state is not None:
         os.makedirs(outpath, exist_ok=True)
-        fig.savefig(os.path.join(outpath, state.replace('.pt', '_cm.png')),
-                    dpi=300, bbox_inches='tight')
+        fig.savefig(os.path.join(outpath, state), dpi=300, bbox_inches='tight')
 
     return fig, ax
 
@@ -195,6 +194,9 @@ def plot_loss(loss_file, figsize=(10, 10), step=5,
     # an epoch
     rm = {k: running_mean(v.flatten('F'), v.shape[0]) for k, v in loss.items()}
 
+    # sort the keys of the dictionary alphabetically
+    rm = {k: rm[k] for k in sorted(rm)}
+
     # number of epochs trained
     epochs = np.arange(0, loss['tl'].shape[1])
 
-- 
GitLab