diff --git a/src/cmsstyle/cmsstyle.py b/src/cmsstyle/cmsstyle.py index 24c336a..80f73ff 100644 --- a/src/cmsstyle/cmsstyle.py +++ b/src/cmsstyle/cmsstyle.py @@ -29,6 +29,12 @@ def SetLumi(lumi, round_lumi=False): cmsText = "CMS" extraText = "Preliminary" + +def SetExtraText(text): + global extraText + extraText = text + + writeExtraText = True cmsTextFont = 61 # default is helvetic-bold @@ -36,6 +42,14 @@ def SetLumi(lumi, round_lumi=False): additionalInfoFont = 42 additionalInfo = [] # For extra info +def ResetAdditionalInfo(): + global additionalInfo + additionalInfo = [] + +def AppendAdditionalInfo(text): + global additionalInfo + additionalInfo.append(text) + # text sizes and text offsets with respect to the top frame in unit of the top margin size lumiTextSize = 0.6 lumiTextOffset = 0.2 diff --git a/tests/example.py b/tests/example.py index 39e7f97..023ded1 100644 --- a/tests/example.py +++ b/tests/example.py @@ -2,7 +2,7 @@ import numpy as np import cmsstyle as CMS -CMS.extraText = "Simulation Preliminary" +CMS.SetExtraText("Simulation Preliminary") class Plotter: @@ -46,10 +46,9 @@ def Plot(self, square, iPos): CMS.SetLumi("138") CMS.SetEnergy("13") # Write extra lines below the extra text (usuful to define regions/channels) - CMS.additionalInfoFont = 42 - CMS.additionalInfo = [] - CMS.additionalInfo.append("Signal region") - CMS.additionalInfo.append("#mu-channel") + CMS.ResetAdditionalInfo() + CMS.AppendAdditionalInfo("Signal region") + CMS.AppendAdditionalInfo("#mu-channel") canv = CMS.cmsCanvas( canv_name,