From f0f42246b390ec932caa30ad2843b015419991f2 Mon Sep 17 00:00:00 2001 From: Marco Cipriani Date: Fri, 26 Dec 2025 16:13:58 +0100 Subject: [PATCH] set y axis lower value with automatic upper value --- bin/rabbit_plot_hists.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/bin/rabbit_plot_hists.py b/bin/rabbit_plot_hists.py index 0df45c9..bb66e0a 100755 --- a/bin/rabbit_plot_hists.py +++ b/bin/rabbit_plot_hists.py @@ -750,6 +750,15 @@ def make_plot( ax1.set_ylim(min_y - range_y * 0.1, max_y + range_y * 0.1) + if args.ylim is not None and args.ylim[0] > args.ylim[1]: + # configuration to set minimum to args.ylim[0] (e.g. 0 when we have event yields) and maximum automatically + max_y = np.max(h_inclusive.values() + h_inclusive.variances() ** 0.5) + if h_data is not None: + max_y = max(max_y, np.max(h_data.values() + h_data.variances() ** 0.5)) + min_y = args.ylim[0] + range_y = max_y - min_y + ax1.set_ylim(min_y, max_y + range_y * 0.1) + if len(axes_names) > 1 and args.binSeparationLines is not None: # plot dashed vertical lines to sepate makro bins