From 8b1f3c2ee863b4fee2fe4134387b1fe1f5507723 Mon Sep 17 00:00:00 2001
From: Nikolai <osterei33@gmx.de>
Date: Tue, 12 Jun 2018 10:24:38 +0200
Subject: [PATCH] option to pass bins and range to plot_score and
 plot_significance

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

diff --git a/toolkit.py b/toolkit.py
index 7f6cad0..75cdbc1 100755
--- a/toolkit.py
+++ b/toolkit.py
@@ -873,8 +873,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))):
         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)
@@ -894,10 +893,9 @@ class ClassificationProject(object):
         fig.savefig(os.path.join(self.project_dir, "scores.pdf"))
 
 
-    def plot_significance(self, lumifactor=1., significanceFunction=None):
+    def plot_significance(self, lumifactor=1., significanceFunction=None, plot_opts=dict(bins=50, range=(0, 1))):
         logger.info("Plot significances")
 
-        plot_opts = dict(bins=50, range=(0, 1))
         centers_sig_train, hist_sig_train, rel_errors_sig_train = self.get_bin_centered_hist(self.scores_train[self.y_train==1].reshape(-1), weights=self.w_train[self.y_train==1], **plot_opts)
         centers_bkg_train, hist_bkg_train, rel_errors_bkg_train = self.get_bin_centered_hist(self.scores_train[self.y_train==0].reshape(-1), 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), weights=self.w_test[self.y_test==1], **plot_opts)
-- 
GitLab