From 2cfd27a3e072ab75634243eba0209c2554445087 Mon Sep 17 00:00:00 2001
From: Klaus Rabbertz <klaus.rabbertz@cern.ch>
Date: Fri, 27 Oct 2023 18:22:40 +0200
Subject: [PATCH] Added a few missing plt.close(fig) statements

---
 tools/plotting/fastnnlo_absolute.py     | 1 +
 tools/plotting/fastnnlo_kfaccomp.py     | 1 +
 tools/plotting/fastnnlo_runtime.py      | 2 ++
 tools/plotting/fastnnlo_scaleclosure.py | 1 +
 4 files changed, 5 insertions(+)

diff --git a/tools/plotting/fastnnlo_absolute.py b/tools/plotting/fastnnlo_absolute.py
index c6926ef7..b15ccd34 100755
--- a/tools/plotting/fastnnlo_absolute.py
+++ b/tools/plotting/fastnnlo_absolute.py
@@ -510,5 +510,6 @@ for i in range(nscl):
             fignam = args['filename']+'.scl'+str(i+1)+'.absolute-index-'+str(ylim2)+'.png'
     if verb: print('[fastnnlo_absolute]: Writing figure: {:s}'.format(fignam))
     plt.savefig(fignam, bbox_inches='tight')
+    plt.close(fig)
 
 exit(0)
diff --git a/tools/plotting/fastnnlo_kfaccomp.py b/tools/plotting/fastnnlo_kfaccomp.py
index 003d1ec0..a029cff2 100755
--- a/tools/plotting/fastnnlo_kfaccomp.py
+++ b/tools/plotting/fastnnlo_kfaccomp.py
@@ -471,5 +471,6 @@ else:
 print('[fastnnlo_kfaccomp]: Writing figure {:s}'.format(fignam))
 
 plt.savefig(fignam)
+plt.close(fig)
 
 exit(0)
diff --git a/tools/plotting/fastnnlo_runtime.py b/tools/plotting/fastnnlo_runtime.py
index 8ce75a9c..2d0b9ef0 100755
--- a/tools/plotting/fastnnlo_runtime.py
+++ b/tools/plotting/fastnnlo_runtime.py
@@ -330,6 +330,7 @@ def plot_elapsed_time(infodict, out_path, out_name, formats):
             filename += channels[0]  + '.' + basename + '.' + fmt
         print('[fastnnlo_runtime]: Saving runtime plot {}'.format(filename))
         fig.savefig(filename)
+    plt.close(fig)
 
 def plot_events_per_hour(infodict, out_path, out_name, formats):
 
@@ -428,6 +429,7 @@ def plot_events_per_hour(infodict, out_path, out_name, formats):
             filename += channels[0]  + '.' + basename + '.' + fmt
         print('[fastnnlo_runtime]: Saving event rate plot {}'.format(filename))
         fig.savefig(filename)
+    plt.close(fig)
 
 if __name__ == "__main__":
     main()
diff --git a/tools/plotting/fastnnlo_scaleclosure.py b/tools/plotting/fastnnlo_scaleclosure.py
index d274f5de..82e80903 100755
--- a/tools/plotting/fastnnlo_scaleclosure.py
+++ b/tools/plotting/fastnnlo_scaleclosure.py
@@ -475,5 +475,6 @@ for i in range(nscl):
     else:
         fignam = args['filename']+'.scl'+str(i+1)+'.scaleclosure-'+str(ylim2)+'.png'
     plt.savefig(fignam)
+    plt.close(fig)
 
 exit(0)
-- 
GitLab