From a027593bbba1928651cf13702b7d56b70ce208e8 Mon Sep 17 00:00:00 2001 From: Nikolai Hartmann <Nikolai.Hartmann@physik.uni-muenchen.de> Date: Wed, 25 Jul 2018 11:22:12 +0200 Subject: [PATCH] ylim option for plot_score --- toolkit.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/toolkit.py b/toolkit.py index 8d36861..5a312a2 100755 --- a/toolkit.py +++ b/toolkit.py @@ -926,7 +926,7 @@ class ClassificationProject(object): plt.clf() - def plot_score(self, log=True, plot_opts=dict(bins=50, range=(0, 1))): + def plot_score(self, log=True, plot_opts=dict(bins=50, range=(0, 1)), ylim=None): centers_sig_train, hist_sig_train, _ = self.get_bin_centered_hist(self.scores_train[self.y_train==1].reshape(-1), density=True, weights=self.w_train[self.y_train==1], **plot_opts) centers_bkg_train, hist_bkg_train, _ = self.get_bin_centered_hist(self.scores_train[self.y_train==0].reshape(-1), density=True, weights=self.w_train[self.y_train==0], **plot_opts) centers_sig_test, hist_sig_test, rel_errors_sig_test = self.get_bin_centered_hist(self.scores_test[self.y_test==1].reshape(-1), density=True, weights=self.w_test[self.y_test==1], **plot_opts) @@ -941,6 +941,8 @@ class ClassificationProject(object): ax.errorbar(centers_sig_test, hist_sig_test, fmt="ro", yerr=errors_sig_test, label="signal test") if log: ax.set_yscale("log") + if ylim is not None: + ax.set_ylim(*ylim) ax.set_xlabel("NN output") fig.legend(loc='upper center', framealpha=0.5) fig.savefig(os.path.join(self.project_dir, "scores.pdf")) -- GitLab