From f51214b2ae99f9f30f3eb277bd39c5256b8af803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ander=20Sim=C3=B3n?= Date: Sun, 17 Jun 2018 21:15:23 +0200 Subject: [PATCH] 483 Fix bug introduced in #482 https://github.com/nextic/IC/pull/483 [author: Aretno] If-related fuck-up, fixed. [reviewer: gonzaponte] Ok. --- invisible_cities/icaro/histogram_plot_functions.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/invisible_cities/icaro/histogram_plot_functions.py b/invisible_cities/icaro/histogram_plot_functions.py index 4159889de2..52af7b84f3 100644 --- a/invisible_cities/icaro/histogram_plot_functions.py +++ b/invisible_cities/icaro/histogram_plot_functions.py @@ -157,11 +157,11 @@ def plot_histograms(histo_manager, histonames='all', n_columns=3, plot_errors=Fa fig, axes = plt.subplots(n_rows, n_columns, figsize=(8 * n_columns, 6 * n_rows)) for i, histoname in enumerate(histonames): + if out_path: + fig, ax = plt.subplots(1, 1, figsize=(8, 6)) + else: + ax = axes.flatten()[i] if isinstance(axes, np.ndarray) else axes if reference_histo: - if out_path: - fig, ax = plt.subplots(1, 1, figsize=(8, 6)) - else: - ax = axes.flatten()[i] if isinstance(axes, np.ndarray) else axes if len(reference_histo[histoname].bins) == 1: plot_histogram(reference_histo[histoname], ax=ax, plot_errors=plot_errors, normed=normed, draw_color='red', stats=False) plot_histogram (histo_manager [histoname], ax=ax, plot_errors=plot_errors, normed=normed) @@ -171,6 +171,9 @@ def plot_histograms(histo_manager, histonames='all', n_columns=3, plot_errors=Fa fig.savefig(out_path + histoname + '.png') fig.clf() plt.close(fig) + if out_path is None: + fig.tight_layout() + def get_percentage(a, b): """