diff --git a/src/cmsstyle/cmsstyle.py b/src/cmsstyle/cmsstyle.py index c1d6ec5..4e78fcf 100644 --- a/src/cmsstyle/cmsstyle.py +++ b/src/cmsstyle/cmsstyle.py @@ -68,6 +68,36 @@ def AppendAdditionalInfo(text): petroff_8 = ["#1845fb", "#ff5e02", "#c91f16", "#c849a9", "#adad7d", "#86c8dd", "#578dff", "#656364"] petroff_10 = ["#3f90da", "#ffa90e", "#bd1f01", "#94a4a2", "#832db6", "#a96b59", "#e76300", "#b9ac70", "#717581", "#92dadd"] +class p6: + kBlue = rt.TColor.GetColor("#5790fc") + kYellow = rt.TColor.GetColor("#f89c20") + kRed = rt.TColor.GetColor("#e42536") + kGrape = rt.TColor.GetColor("#964a8b") + kGray = rt.TColor.GetColor("#9c9ca1") + kViolet = rt.TColor.GetColor("#7a21dd") + +class p8: + kBlue = rt.TColor.GetColor("#1845fb") + kOrange = rt.TColor.GetColor("#ff5e02") + kRed = rt.TColor.GetColor("#c91f16") + kPink = rt.TColor.GetColor("#c849a9") + kGreen = rt.TColor.GetColor("#adad7d") + kCyan = rt.TColor.GetColor("#86c8dd") + kAzure = rt.TColor.GetColor("#578dff") + kGray = rt.TColor.GetColor("#656364") + +class p10: + kBlue = rt.TColor.GetColor("#3f90da") + kYellow = rt.TColor.GetColor("#ffa90e") + kRed = rt.TColor.GetColor("#bd1f01") + kGray = rt.TColor.GetColor("#94a4a2") + kViolet = rt.TColor.GetColor("#832db6") + kBrown = rt.TColor.GetColor("#a96b59") + kOrange = rt.TColor.GetColor("#e76300") + kGreen = rt.TColor.GetColor("#b9ac70") + kAsh = rt.TColor.GetColor("#717581") + kCyan = rt.TColor.GetColor("#92dadd") + # Define an alternative color palette and a function to set it MyPalette = None diff --git a/tests/example.py b/tests/example.py index 35dfb1d..b986a13 100644 --- a/tests/example.py +++ b/tests/example.py @@ -67,13 +67,11 @@ def Plot(self, square, iPos): leg = CMS.cmsLeg(0.60, 0.89 - 0.04 * 4, 0.89, 0.89, textSize=0.04) # Draw objects in one line - CMS.cmsDraw(self.bkg, "hist", fcolor=ROOT.kAzure + 2, alpha=0.5) - CMS.cmsDraw(self.signal, "hist", fcolor=ROOT.kRed + 1, alpha=0.5) + stack = ROOT.THStack("stack", "Stacked") + leg.AddEntry(self.data, "Data", "lp") + CMS.cmsDrawStack(stack, leg, {"Background": self.bkg, "Signal": self.signal}) CMS.cmsDraw(self.data, "P", mcolor=ROOT.kBlack) - leg.AddEntry(self.data, "Data", "lp") - leg.AddEntry(self.bkg, "Background", "f") - leg.AddEntry(self.signal, "Signal", "f") # Takes care of fixing overlay and closing object CMS.SaveCanvas(canv, os.path.join(self.outputPath, canv_name + ".pdf")) @@ -98,20 +96,18 @@ def Plot(self, square, iPos): leg = CMS.cmsLeg(0.60, 0.89 - 0.05 * 5, 0.89, 0.89, textSize=0.05) leg.AddEntry(self.data, "Data", "lp") - leg.AddEntry(self.bkg, "Background", "f") - leg.AddEntry(self.signal, "Signal", "f") CMS.cmsHeader(leg, "With title", textSize=0.05) - CMS.cmsDraw(self.bkg_tot, "hist", fcolor=ROOT.kRed + 1, alpha=0.5) - CMS.cmsDraw(self.bkg, "hist", fcolor=ROOT.kAzure + 2, alpha=0.9) + stack = ROOT.THStack("stack", "Stacked") + CMS.cmsDrawStack(stack, leg, {"Background": self.bkg, "Signal": self.signal}) CMS.cmsDraw(self.data, "P", mcolor=ROOT.kBlack) CMS.fixOverlay() dicanv.cd(2) leg_ratio = CMS.cmsLeg( - 0.17, 0.97 - 0.05 * 5, 0.35, 0.97, textSize=0.05, columns=2 + 0.67, 0.97 - 0.05 * 5, 0.85, 0.97, textSize=0.05, columns=2 ) # how alternative way to pass style options style = {"style": "hist", "lcolor": ROOT.kAzure + 2, "lwidth": 2, "fstyle": 0} @@ -156,7 +152,6 @@ def Plot2D(self, square, iPos): CMS.SaveCanvas(canv, os.path.join(self.outputPath, canv_name + ".pdf")) - def main(): plotter = Plotter() plotter.Plot(square=CMS.kSquare, iPos=0) diff --git a/tests/pdfs/example_2D_rectangle_pos0.pdf b/tests/pdfs/example_2D_rectangle_pos0.pdf index 56169e2..36cfbba 100644 Binary files a/tests/pdfs/example_2D_rectangle_pos0.pdf and b/tests/pdfs/example_2D_rectangle_pos0.pdf differ diff --git a/tests/pdfs/example_2D_square_pos0.pdf b/tests/pdfs/example_2D_square_pos0.pdf index 2a3e2e8..b316016 100644 Binary files a/tests/pdfs/example_2D_square_pos0.pdf and b/tests/pdfs/example_2D_square_pos0.pdf differ diff --git a/tests/pdfs/example_rectangle_pos0.pdf b/tests/pdfs/example_rectangle_pos0.pdf index c090e5e..324c9df 100644 Binary files a/tests/pdfs/example_rectangle_pos0.pdf and b/tests/pdfs/example_rectangle_pos0.pdf differ diff --git a/tests/pdfs/example_rectangle_pos0_ratio.pdf b/tests/pdfs/example_rectangle_pos0_ratio.pdf index 87adc39..58e70d9 100644 Binary files a/tests/pdfs/example_rectangle_pos0_ratio.pdf and b/tests/pdfs/example_rectangle_pos0_ratio.pdf differ diff --git a/tests/pdfs/example_rectangle_pos11.pdf b/tests/pdfs/example_rectangle_pos11.pdf index 5b38aba..232d76a 100644 Binary files a/tests/pdfs/example_rectangle_pos11.pdf and b/tests/pdfs/example_rectangle_pos11.pdf differ diff --git a/tests/pdfs/example_rectangle_pos11_ratio.pdf b/tests/pdfs/example_rectangle_pos11_ratio.pdf index b351d6b..6321aa0 100644 Binary files a/tests/pdfs/example_rectangle_pos11_ratio.pdf and b/tests/pdfs/example_rectangle_pos11_ratio.pdf differ diff --git a/tests/pdfs/example_square_pos0.pdf b/tests/pdfs/example_square_pos0.pdf index d875f69..760acd7 100644 Binary files a/tests/pdfs/example_square_pos0.pdf and b/tests/pdfs/example_square_pos0.pdf differ diff --git a/tests/pdfs/example_square_pos0_ratio.pdf b/tests/pdfs/example_square_pos0_ratio.pdf index 14bf068..64d7f05 100644 Binary files a/tests/pdfs/example_square_pos0_ratio.pdf and b/tests/pdfs/example_square_pos0_ratio.pdf differ diff --git a/tests/pdfs/example_square_pos11.pdf b/tests/pdfs/example_square_pos11.pdf index 713d909..d39b953 100644 Binary files a/tests/pdfs/example_square_pos11.pdf and b/tests/pdfs/example_square_pos11.pdf differ diff --git a/tests/pdfs/example_square_pos11_ratio.pdf b/tests/pdfs/example_square_pos11_ratio.pdf index 41d1a5d..e0fc6de 100644 Binary files a/tests/pdfs/example_square_pos11_ratio.pdf and b/tests/pdfs/example_square_pos11_ratio.pdf differ