From 912a46e55e8bcf24426dd756446b9774a28aeda2 Mon Sep 17 00:00:00 2001 From: Lukas Lechner Date: Thu, 6 Jun 2019 17:38:53 +0200 Subject: [PATCH 1/2] adding auto zRange support for 2D plotting --- plot/python/plotting.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plot/python/plotting.py b/plot/python/plotting.py index 6ea2662..3cfc7eb 100644 --- a/plot/python/plotting.py +++ b/plot/python/plotting.py @@ -626,8 +626,18 @@ def draw2D(plot, \ c1.SetLogz(logZ) histo.GetXaxis().SetTitle(plot.texX) histo.GetYaxis().SetTitle(plot.texY) - if zRange is not None: - histo.GetZaxis().SetRangeUser( *zRange ) + + # Range on z axis: Start with default + if not zRange=="auto" and not (type(zRange)==type(()) and len(zRange)==2): + raise ValueError( "'zRange' must bei either 'auto' or (zMin, zMax) where zMin/zMax can be 'auto'. Got: %r"%zRange ) + + if (type(zRange)==type(()) and len(zRange)==2) and zRange[0] != "auto": + histo.SetMinimum(zRange[0]) + if (type(zRange)==type(()) and len(zRange)==2) and zRange[1] != "auto": + histo.SetMaximum(zRange[1]) + +# if zRange is not None: +# histo.GetZaxis().SetRangeUser( *zRange ) # precision 3 fonts. see https://root.cern.ch/root/htmldoc//TAttText.html#T5 histo.GetXaxis().SetTitleFont(43) histo.GetYaxis().SetTitleFont(43) From e4941f12445d4bb1301f902257afd94be6091968 Mon Sep 17 00:00:00 2001 From: Lukas Lechner Date: Thu, 6 Jun 2019 17:39:34 +0200 Subject: [PATCH 2/2] change staticmethod to be consistent with Plot.py --- plot/python/Plot2D.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plot/python/Plot2D.py b/plot/python/Plot2D.py index f6feceb..64aa601 100644 --- a/plot/python/Plot2D.py +++ b/plot/python/Plot2D.py @@ -27,7 +27,7 @@ def setDefaults(stack = None, attribute = None, binning = None, name = None, sel Plot2D.defaultBinning = binning Plot2D.defaultName = name Plot2D.defaultSelectionString = selectionString - Plot2D.defaultWeight = staticmethod(weight) + Plot2D.defaultWeight = weight Plot2D.defaultHistoClass = histo_class Plot2D.defaultTexX = texX Plot2D.defaultTexY = texY