Skip to content

Commit 687a4f0

Browse files
authored
Merge pull request #49 from oglez/master
Changing the way the style is forced in the cmsStyle to allow changing parameters
2 parents 0ca9cd0 + b531b9e commit 687a4f0

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/cmsstyle/cmsstyle.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def SetExtraText(text):
7474

7575
def SetCmsTextFont(font):
7676
"""
77-
Function that allows to edit th default font of the
77+
Function that allows to edit the default font of the
7878
"CMS" string
7979
8080
Args:
@@ -119,7 +119,7 @@ def AppendAdditionalInfo(text):
119119

120120
def SetCmsTextSize(size):
121121
"""
122-
Function that allows to edit th default fontsize of the
122+
Function that allows to edit the default fontsize of the
123123
"CMS" string
124124
125125
Args:
@@ -351,13 +351,13 @@ def UpdatePad(pad=None):
351351
rt.gPad.Update()
352352

353353

354-
def setCMSStyle():
354+
def setCMSStyle(force=rt.kTRUE):
355355
global cmsStyle
356356
if cmsStyle != None:
357357
del cmsStyle
358358
cmsStyle = rt.TStyle("cmsStyle", "Style for P-CMS")
359359
rt.gROOT.SetStyle(cmsStyle.GetName())
360-
rt.gROOT.ForceStyle()
360+
rt.gROOT.ForceStyle(force)
361361
# for the canvas:
362362
cmsStyle.SetCanvasBorderMode(0)
363363
cmsStyle.SetCanvasColor(rt.kWhite)
@@ -629,7 +629,7 @@ def cmsCanvas(
629629
"""
630630

631631
# Set CMS style
632-
setCMSStyle()
632+
if cmsStyle is None: setCMSStyle()
633633

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

971971

@@ -991,7 +991,7 @@ def cmsDrawStack(stack, legend, MC, data = None, palette = None, invertLegendEnt
991991
print("Length of provided palette is smaller than the number of histograms to be drawn, wrap around is enabled")
992992
else:
993993
print("Invalid palette elements provided, default palette will be used")
994-
994+
995995
if palette == None or is_user_palette_valid == False:
996996
if len(MC.keys()) < 7:
997997
palette_ = petroff_6
@@ -1013,7 +1013,7 @@ def cmsDrawStack(stack, legend, MC, data = None, palette = None, invertLegendEnt
10131013
if not invertLegendEntries:
10141014
legend.AddEntry(item[1], item[0], "f")
10151015
stack.Draw("HIST SAME")
1016-
1016+
10171017
if data != None:
10181018
cmsDraw(data, "P", mcolor=rt.kBlack)
10191019
legend.AddEntry(data, "Data", "lp")

0 commit comments

Comments
 (0)