Skip to content

Commit

Permalink
Changing the way cmsStyle handles and forces the style (and rebasing …
Browse files Browse the repository at this point in the history
…commits b922e3e and 38961fb)
  • Loading branch information
oglez committed Sep 28, 2024
1 parent 0ca9cd0 commit b531b9e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/cmsstyle/cmsstyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def SetExtraText(text):

def SetCmsTextFont(font):
"""
Function that allows to edit th default font of the
Function that allows to edit the default font of the
"CMS" string
Args:
Expand Down Expand Up @@ -119,7 +119,7 @@ def AppendAdditionalInfo(text):

def SetCmsTextSize(size):
"""
Function that allows to edit th default fontsize of the
Function that allows to edit the default fontsize of the
"CMS" string
Args:
Expand Down Expand Up @@ -351,13 +351,13 @@ def UpdatePad(pad=None):
rt.gPad.Update()


def setCMSStyle():
def setCMSStyle(force=rt.kTRUE):
global cmsStyle
if cmsStyle != None:
del cmsStyle
cmsStyle = rt.TStyle("cmsStyle", "Style for P-CMS")
rt.gROOT.SetStyle(cmsStyle.GetName())
rt.gROOT.ForceStyle()
rt.gROOT.ForceStyle(force)
# for the canvas:
cmsStyle.SetCanvasBorderMode(0)
cmsStyle.SetCanvasColor(rt.kWhite)
Expand Down Expand Up @@ -629,7 +629,7 @@ def cmsCanvas(
"""

# Set CMS style
setCMSStyle()
if cmsStyle is None: setCMSStyle()

# Set canvas dimensions and margins
W_ref = 600 if square else 800
Expand Down Expand Up @@ -965,7 +965,7 @@ def is_valid_hex_color(hex_color):
bool: True if the string is a valid hexadecimal color code, False otherwise.
"""
hex_color_pattern = re.compile(r'^#(?:[0-9a-fA-F]{3}){1,2}$')

return bool(hex_color_pattern.match(hex_color))


Expand All @@ -991,7 +991,7 @@ def cmsDrawStack(stack, legend, MC, data = None, palette = None, invertLegendEnt
print("Length of provided palette is smaller than the number of histograms to be drawn, wrap around is enabled")
else:
print("Invalid palette elements provided, default palette will be used")

if palette == None or is_user_palette_valid == False:
if len(MC.keys()) < 7:
palette_ = petroff_6
Expand All @@ -1013,7 +1013,7 @@ def cmsDrawStack(stack, legend, MC, data = None, palette = None, invertLegendEnt
if not invertLegendEntries:
legend.AddEntry(item[1], item[0], "f")
stack.Draw("HIST SAME")

if data != None:
cmsDraw(data, "P", mcolor=rt.kBlack)
legend.AddEntry(data, "Data", "lp")
Expand Down

0 comments on commit b531b9e

Please sign in to comment.