From bd714c5ae8d5be3d5112d2f9e8b63c67153b4d94 Mon Sep 17 00:00:00 2001
From: Philipp Arras <parras@mpa-garching.mpg.de>
Date: Tue, 13 Jul 2021 15:02:11 +0200
Subject: [PATCH] Plotting: Automatic distribution

---
 src/plot.py | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/plot.py b/src/plot.py
index 1b3c05a54..198f72b26 100644
--- a/src/plot.py
+++ b/src/plot.py
@@ -26,7 +26,7 @@ from .domains.power_space import PowerSpace
 from .domains.rg_space import RGSpace
 from .field import Field
 from .minimization.iteration_controllers import EnergyHistory
-from .utilities import check_domain_equality
+from .utilities import check_domain_equality, myassert
 
 # relevant properties:
 # - x/y size
@@ -578,7 +578,9 @@ class Plot:
         nx = kwargs.pop("nx", 0)
         ny = kwargs.pop("ny", 0)
         if nx == ny == 0:
-            nx = ny = int(np.ceil(np.sqrt(nplot)))
+            ny = int(np.ceil(np.sqrt(nplot)))
+            nx = int(np.ceil(nplot/ny))
+            myassert(nx*ny >= nplot)
         elif nx == 0:
             nx = int(np.ceil(nplot/ny))
         elif ny == 0:
-- 
GitLab