Skip to content

Commit

Permalink
add methods to customize extra and additional text
Browse files Browse the repository at this point in the history
  • Loading branch information
ttedeschi committed Dec 4, 2023
1 parent edca60c commit c3b6d94
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
14 changes: 14 additions & 0 deletions src/cmsstyle/cmsstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,27 @@ 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
extraTextFont = 52 # default is helvetica-italics
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
Expand Down
9 changes: 4 additions & 5 deletions tests/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import numpy as np
import cmsstyle as CMS

CMS.extraText = "Simulation Preliminary"
CMS.SetExtraText("Simulation Preliminary")


class Plotter:
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit c3b6d94

Please sign in to comment.