From b43f6fb0ecc7e6ac5b1e861d6a339ff0dfdbd1b2 Mon Sep 17 00:00:00 2001 From: Jonas Rembser Date: Mon, 25 Nov 2024 12:26:27 +0100 Subject: [PATCH] Use strings for colors in Python tutorials This makes the code less verbose and more pythonic. --- .../pythonizations/test/roofit/rooabsreal_ploton.py | 4 ++-- tree/dataframe/src/RDataFrame.cxx | 2 +- tutorials/dataframe/df103_NanoAODHiggsAnalysis.py | 10 +++++----- tutorials/dataframe/df104_HiggsToTwoPhotons.py | 2 +- tutorials/dataframe/df105_WBosonAnalysis.py | 2 +- tutorials/dataframe/df106_HiggsToFourLeptons.py | 10 +++++----- tutorials/dataframe/df107_SingleTopAnalysis.py | 2 +- tutorials/fit/combinedFit.py | 4 ++-- tutorials/graphs/timeSeriesFromCSV.py | 2 +- tutorials/hist/twoscales.py | 6 +++--- tutorials/histfactory/hf001_example.py | 6 +++--- tutorials/pyroot/shapes.py | 6 +++--- tutorials/pyroot/zdemo.py | 8 ++++---- tutorials/rcanvas/df104.py | 2 +- tutorials/rcanvas/df105.py | 2 +- tutorials/roofit/rf106_plotdecoration.py | 6 +++--- tutorials/roofit/rf211_paramconv.py | 2 +- tutorials/roofit/rf301_composition.py | 2 +- tutorials/roofit/rf302_utilfuncs.py | 8 ++++---- tutorials/roofit/rf305_condcorrprod.py | 2 +- tutorials/roofit/rf306_condpereventerrors.py | 2 +- tutorials/roofit/rf307_fullpereventerrors.py | 2 +- tutorials/roofit/rf308_normintegration2d.py | 2 +- tutorials/roofit/rf309_ndimplot.py | 4 ++-- tutorials/roofit/rf315_projectpdf.py | 2 +- tutorials/roofit/rf608_fitresultaspdf.py | 8 ++++---- tutorials/roofit/rf615_simulation_based_inference.py | 8 ++++---- ...f617_simulation_based_inference_multidimensional.py | 8 ++++---- tutorials/roofit/rf702_efficiencyfit_2D.py | 2 +- tutorials/roofit/rf704_amplitudefit.py | 4 ++-- tutorials/roofit/rf705_linearmorph.py | 2 +- tutorials/roofit/rf707_kernelestimation.py | 4 ++-- tutorials/roofit/rf710_roopoly.py | 4 ++-- tutorials/roofit/rf711_lagrangianmorph.py | 10 +++++----- tutorials/roofit/rf802_mcstudy_addons.py | 4 ++-- tutorials/roostats/IntervalExamples.py | 2 +- tutorials/roostats/MultivariateGaussianTest.py | 2 +- tutorials/roostats/Zbi_Zgamma.py | 2 +- tutorials/roostats/rs101_limitexample.py | 8 ++++---- tutorials/roostats/rs401c_FeldmanCousins.py | 4 ++-- tutorials/roostats/rs_bernsteinCorrection.py | 2 +- tutorials/tmva/TMVA_SOFIE_Inference.py | 4 ++-- tutorials/tmva/TMVA_SOFIE_Models.py | 10 +++++----- tutorials/tmva/TMVA_SOFIE_RDataFrame.py | 4 ++-- tutorials/tmva/tmva102_Testing.py | 2 +- 45 files changed, 97 insertions(+), 97 deletions(-) diff --git a/bindings/pyroot/pythonizations/test/roofit/rooabsreal_ploton.py b/bindings/pyroot/pythonizations/test/roofit/rooabsreal_ploton.py index 4a8aecd313276..5d333e9c0b531 100644 --- a/bindings/pyroot/pythonizations/test/roofit/rooabsreal_ploton.py +++ b/bindings/pyroot/pythonizations/test/roofit/rooabsreal_ploton.py @@ -18,8 +18,8 @@ class RooAbsRealPlotOn(unittest.TestCase): def test_frame(self): # test that kwargs can be passed # and lead to correct result - r1 = self.gauss.plotOn(self.xframe, ROOT.RooFit.LineColor(ROOT.kRed)) - r2 = self.gauss.plotOn(self.xframe, LineColor=ROOT.kRed) + r1 = self.gauss.plotOn(self.xframe, LineColor="r") + r2 = self.gauss.plotOn(self.xframe, LineColor="r") def test_wrong_kwargs(self): # test that AttributeError is raised diff --git a/tree/dataframe/src/RDataFrame.cxx b/tree/dataframe/src/RDataFrame.cxx index 8497a2c19f498..1f24f9d7f0379 100644 --- a/tree/dataframe/src/RDataFrame.cxx +++ b/tree/dataframe/src/RDataFrame.cxx @@ -899,7 +899,7 @@ You can also include a global callback function that will be applied to all plot ~~~{.py} def set_fill_color(hist): - hist.SetFillColor(ROOT.kBlue) + hist.SetFillColor("kBlue") LiveVisualize([h_gaus, h_exp, h_random], set_fill_color) ~~~ diff --git a/tutorials/dataframe/df103_NanoAODHiggsAnalysis.py b/tutorials/dataframe/df103_NanoAODHiggsAnalysis.py index 52b0fadea6e21..7cf6d17d647b6 100644 --- a/tutorials/dataframe/df103_NanoAODHiggsAnalysis.py +++ b/tutorials/dataframe/df103_NanoAODHiggsAnalysis.py @@ -206,23 +206,23 @@ def plot(sig, bkg, data, x_label, filename): h_cmb.GetXaxis().SetTitleSize(0.04) h_cmb.GetYaxis().SetTitle("N_{Events}") h_cmb.GetYaxis().SetTitleSize(0.04) - h_cmb.SetLineColor(ROOT.kRed) + h_cmb.SetLineColor("kRed") h_cmb.SetLineWidth(2) h_cmb.SetMaximum(18) h_cmb.SetStats(False) h_bkg.SetLineWidth(2) h_bkg.SetFillStyle(1001) - h_bkg.SetLineColor(ROOT.kBlack) - h_bkg.SetFillColor(ROOT.kAzure - 9) + h_bkg.SetLineColor("kBlack") + h_bkg.SetFillColor("kAzure - 9") # Get histogram of data points h_data = data.Clone() h_data.SetLineWidth(1) h_data.SetMarkerStyle(20) h_data.SetMarkerSize(1.0) - h_data.SetMarkerColor(ROOT.kBlack) - h_data.SetLineColor(ROOT.kBlack) + h_data.SetMarkerColor("kBlack") + h_data.SetLineColor("kBlack") # Draw histograms h_cmb.Draw("HIST") diff --git a/tutorials/dataframe/df104_HiggsToTwoPhotons.py b/tutorials/dataframe/df104_HiggsToTwoPhotons.py index 852ff0dff6060..6cbe9395bf2c1 100644 --- a/tutorials/dataframe/df104_HiggsToTwoPhotons.py +++ b/tutorials/dataframe/df104_HiggsToTwoPhotons.py @@ -127,7 +127,7 @@ data.SetMarkerStyle(20) data.SetMarkerSize(1.2) data.SetLineWidth(2) -data.SetLineColor(ROOT.kBlack) +data.SetLineColor("kBlack") data.SetMinimum(1e-3) data.SetMaximum(8e3) data.GetYaxis().SetLabelSize(0.045) diff --git a/tutorials/dataframe/df105_WBosonAnalysis.py b/tutorials/dataframe/df105_WBosonAnalysis.py index 1a33096ea26c4..54f7516f15bc1 100644 --- a/tutorials/dataframe/df105_WBosonAnalysis.py +++ b/tutorials/dataframe/df105_WBosonAnalysis.py @@ -190,7 +190,7 @@ def merge_histos(label): data.SetMarkerStyle(20) data.SetMarkerSize(1.2) data.SetLineWidth(2) -data.SetLineColor(ROOT.kBlack) +data.SetLineColor("kBlack") data.Draw("E SAME") # Add legend diff --git a/tutorials/dataframe/df106_HiggsToFourLeptons.py b/tutorials/dataframe/df106_HiggsToFourLeptons.py index 8f9f392f0e1b7..7ac109fca496b 100644 --- a/tutorials/dataframe/df106_HiggsToFourLeptons.py +++ b/tutorials/dataframe/df106_HiggsToFourLeptons.py @@ -232,7 +232,7 @@ class VaryHelper h_zz = histos[2].GetValue().Clone() h_other = histos[3].GetValue().Clone() -for h, color in zip([h_other, h_zz, h_higgs], [ROOT.kViolet - 9, ROOT.kAzure - 9, ROOT.kRed + 2]): +for h, color in zip([h_other, h_zz, h_higgs], ["kViolet - 9", "kAzure - 9", "kRed + 2"]): h.SetLineWidth(1) h.SetLineColor(1) h.SetFillColor(color) @@ -250,19 +250,19 @@ class VaryHelper stack.GetYaxis().ChangeLabel(1, -1, 0) # Draw MC scale factor and variations -histos_mc["nominal"].SetFillColor(ROOT.kBlack) +histos_mc["nominal"].SetFillColor("kBlack") histos_mc["nominal"].SetFillStyle(3254) h_nominal = histos_mc["nominal"].DrawClone("E2 same") -histos_mc["weight:up"].SetLineColor(ROOT.kGreen + 2) +histos_mc["weight:up"].SetLineColor("kGreen + 2") h_weight_up = histos_mc["weight:up"].DrawClone("HIST SAME") -histos_mc["weight:down"].SetLineColor(ROOT.kBlue + 2) +histos_mc["weight:down"].SetLineColor("kBlue + 2") h_weight_down = histos_mc["weight:down"].DrawClone("HIST SAME") # Draw data histogram h_data.SetMarkerStyle(20) h_data.SetMarkerSize(1.2) h_data.SetLineWidth(2) -h_data.SetLineColor(ROOT.kBlack) +h_data.SetLineColor("kBlack") h_data.Draw("E SAME") # Draw raw data with errorbars # Add legend diff --git a/tutorials/dataframe/df107_SingleTopAnalysis.py b/tutorials/dataframe/df107_SingleTopAnalysis.py index 328d69ed27fbd..aaa3ba0d49e37 100644 --- a/tutorials/dataframe/df107_SingleTopAnalysis.py +++ b/tutorials/dataframe/df107_SingleTopAnalysis.py @@ -229,7 +229,7 @@ def merge_histos(label): data.SetMarkerStyle(20) data.SetMarkerSize(1.2) data.SetLineWidth(2) -data.SetLineColor(ROOT.kBlack) +data.SetLineColor("kBlack") data.Draw("E SAME") # Add legend diff --git a/tutorials/fit/combinedFit.py b/tutorials/fit/combinedFit.py index 4a452dc5c0122..ddf7c3e6e06c1 100644 --- a/tutorials/fit/combinedFit.py +++ b/tutorials/fit/combinedFit.py @@ -121,14 +121,14 @@ def __call__(self, par): fB.SetFitResult(result, iparB) fB.SetRange(rangeB().first, rangeB().second) -fB.SetLineColor(ROOT.kBlue) +fB.SetLineColor("kBlue") hB.GetListOfFunctions().Add(fB) hB.Draw() c1.cd(2) fSB.SetFitResult(result, iparSB) fSB.SetRange(rangeSB().first, rangeSB().second) -fSB.SetLineColor(ROOT.kRed) +fSB.SetLineColor("kRed") hSB.GetListOfFunctions().Add(fSB) hSB.Draw() diff --git a/tutorials/graphs/timeSeriesFromCSV.py b/tutorials/graphs/timeSeriesFromCSV.py index 4ae37ac5dbe7c..b3fd429008d5e 100644 --- a/tutorials/graphs/timeSeriesFromCSV.py +++ b/tutorials/graphs/timeSeriesFromCSV.py @@ -39,7 +39,7 @@ c.SetRightMargin(0.04) c.SetGrid() g.SetLineWidth(3) -g.SetLineColor(ROOT.kBlue) +g.SetLineColor("kBlue") g.Draw("al") g.GetYaxis().CenterTitle() diff --git a/tutorials/hist/twoscales.py b/tutorials/hist/twoscales.py index b2fa30ea8ff85..436a656bff816 100644 --- a/tutorials/hist/twoscales.py +++ b/tutorials/hist/twoscales.py @@ -39,12 +39,12 @@ rightmax = 1.1*hint1.GetMaximum() scale = ROOT.gPad.GetUymax()/rightmax -hint1.SetLineColor(ROOT.kRed) +hint1.SetLineColor("kRed") hint1.Scale(scale) hint1.Draw("same") axis = ROOT.TGaxis(ROOT.gPad.GetUxmax(),ROOT.gPad.GetUymin(), ROOT.gPad.GetUxmax(), ROOT.gPad.GetUymax(),0,rightmax,510,"+L") -axis.SetLineColor(ROOT.kRed) -axis.SetLabelColor(ROOT.kRed) +axis.SetLineColor("kRed") +axis.SetLabelColor("kRed") axis.Draw() diff --git a/tutorials/histfactory/hf001_example.py b/tutorials/histfactory/hf001_example.py index 206c579ab14f8..cf13fed71dd4e 100755 --- a/tutorials/histfactory/hf001_example.py +++ b/tutorials/histfactory/hf001_example.py @@ -108,11 +108,11 @@ xmax = poi.getMax() line = ROOT.TLine(xmin, 0.5, xmax, 0.5) -line.SetLineColor(ROOT.kGreen) +line.SetLineColor("kGreen") line90 = ROOT.TLine(xmin, 2.71 / 2, xmax, 2.71 / 2) -line90.SetLineColor(ROOT.kGreen) +line90.SetLineColor("kGreen") line95 = ROOT.TLine(xmin, 3.84 / 2, xmax, 3.84 / 2) -line95.SetLineColor(ROOT.kGreen) +line95.SetLineColor("kGreen") frame.addObject(line) frame.addObject(line90) diff --git a/tutorials/pyroot/shapes.py b/tutorials/pyroot/shapes.py index d57e972f3444b..1149d79f8e140 100644 --- a/tutorials/pyroot/shapes.py +++ b/tutorials/pyroot/shapes.py @@ -61,9 +61,9 @@ cons.SetLineColor( 3 ) pcon.SetLineColor( 6 ) pgon.SetLineColor( 2 ) -sphe.SetLineColor( ROOT.kRed ) -sphe1.SetLineColor( ROOT.kBlack ) -sphe2.SetLineColor( ROOT.kBlue ) +sphe.SetLineColor("kRed") +sphe1.SetLineColor("kBlack") +sphe2.SetLineColor("kBlue") # Build the geometry hierarchy node1 = ROOT.TNode( 'NODE1', 'NODE1', 'BRIK' ) diff --git a/tutorials/pyroot/zdemo.py b/tutorials/pyroot/zdemo.py index 603c7cb6d25bf..6aa17b260084d 100644 --- a/tutorials/pyroot/zdemo.py +++ b/tutorials/pyroot/zdemo.py @@ -175,9 +175,9 @@ def zdemo(): t.DrawLatex( 0.18, 0.40, '(barn/Gev^{2})' ) t.SetTextSize( 0.045 ) - t.SetTextColor( ROOT.kBlue ) + t.SetTextColor("kBlue") t.DrawLatex( 0.22, 0.260, '#sqrt{s} = 63(GeV)' ) - t.SetTextColor( ROOT.kRed ) + t.SetTextColor("kRed") t.DrawLatex( 0.22, 0.205,'#sqrt{s} = 200(GeV)' ) t.SetTextColor( 6 ) t.DrawLatex( 0.22, 0.15, '#sqrt{s} = 500(GeV)' ) @@ -210,7 +210,7 @@ def zdemo(): gr2 = ROOT.TGraph( NLOOP, PT, INVSIG ) gr2.SetLineColor( 38 ) - gr2.SetMarkerColor( ROOT.kRed ) + gr2.SetMarkerColor("kRed") gr2.SetMarkerStyle( 29 ) gr2.SetMarkerSize( 1.5 ) gr2.Draw( 'LP' ) @@ -246,7 +246,7 @@ def zdemo(): saves[ 'graph' ] = graph graph = ROOT.TGraph( 1, dum, dum ) - graph.SetMarkerColor( ROOT.kRed ) + graph.SetMarkerColor("Red") graph.SetMarkerStyle( 29 ) graph.SetMarkerSize( 1.5 ) graph.SetPoint( 0, 1.7, 2.e-17 ) diff --git a/tutorials/rcanvas/df104.py b/tutorials/rcanvas/df104.py index 43fb1f4687d51..33d67a9dd123a 100644 --- a/tutorials/rcanvas/df104.py +++ b/tutorials/rcanvas/df104.py @@ -130,7 +130,7 @@ data.SetMarkerStyle(20) data.SetMarkerSize(1.2) data.SetLineWidth(2) -data.SetLineColor(ROOT.kBlack) +data.SetLineColor("kBlack") data.SetMinimum(1e-3) data.SetMaximum(8e3) data.GetYaxis().SetLabelSize(0.045) diff --git a/tutorials/rcanvas/df105.py b/tutorials/rcanvas/df105.py index 480b0fb4c0586..732ec5670eb57 100644 --- a/tutorials/rcanvas/df105.py +++ b/tutorials/rcanvas/df105.py @@ -202,7 +202,7 @@ def merge_histos(label): data.SetMarkerStyle(20) data.SetMarkerSize(1.2) data.SetLineWidth(2) -data.SetLineColor(ROOT.kBlack) +data.SetLineColor("kBlack") c.Add[TObjectDrawable]().Set(data, "E SAME") # Add TLegend while histograms packed in the THStack diff --git a/tutorials/roofit/rf106_plotdecoration.py b/tutorials/roofit/rf106_plotdecoration.py index 1c4e0ee0a95b6..9a2e9e684dc33 100644 --- a/tutorials/roofit/rf106_plotdecoration.py +++ b/tutorials/roofit/rf106_plotdecoration.py @@ -55,13 +55,13 @@ # Add text to frame txt = ROOT.TText(2, 100, "Signal") txt.SetTextSize(0.04) -txt.SetTextColor(ROOT.kRed) +txt.SetTextColor("kRed") frame.addObject(txt) # Add arrow to frame arrow = ROOT.TArrow(2, 100, -1, 50, 0.01, "|>") -arrow.SetLineColor(ROOT.kRed) -arrow.SetFillColor(ROOT.kRed) +arrow.SetLineColor("kRed") +arrow.SetFillColor("kRed") arrow.SetLineWidth(3) frame.addObject(arrow) diff --git a/tutorials/roofit/rf211_paramconv.py b/tutorials/roofit/rf211_paramconv.py index 0dcac0638209b..07f6841197088 100644 --- a/tutorials/roofit/rf211_paramconv.py +++ b/tutorials/roofit/rf211_paramconv.py @@ -63,7 +63,7 @@ ConditionalObservables={mean}, ) hh.SetTitle("histogram of model(x|mean)") -hh.SetLineColor(ROOT.kBlue) +hh.SetLineColor("kBlue") # Draw frame on canvas c = ROOT.TCanvas("rf211_paramconv", "rf211_paramconv", 800, 400) diff --git a/tutorials/roofit/rf301_composition.py b/tutorials/roofit/rf301_composition.py index 109e2dc439da5..fe6d2da946bf8 100644 --- a/tutorials/roofit/rf301_composition.py +++ b/tutorials/roofit/rf301_composition.py @@ -51,7 +51,7 @@ # Make two-dimensional plot in x vs y hh_model = model.createHistogram("hh_model", x, Binning=50, YVar=dict(var=y, Binning=50)) -hh_model.SetLineColor(ROOT.kBlue) +hh_model.SetLineColor("kBlue") # Make canvas and draw ROOT.RooPlots c = ROOT.TCanvas("rf301_composition", "rf301_composition", 1200, 400) diff --git a/tutorials/roofit/rf302_utilfuncs.py b/tutorials/roofit/rf302_utilfuncs.py index 467170454e902..fba185fd90ca5 100644 --- a/tutorials/roofit/rf302_utilfuncs.py +++ b/tutorials/roofit/rf302_utilfuncs.py @@ -69,10 +69,10 @@ hh_model_2 = model_2.createHistogram("hh_model_2", x, Binning=50, YVar=dict(var=y, Binning=50)) hh_model_3 = model_3.createHistogram("hh_model_3", x, Binning=50, YVar=dict(var=y, Binning=50)) hh_model_4 = model_4.createHistogram("hh_model_4", x, Binning=50, YVar=dict(var=y, Binning=50)) -hh_model_1.SetLineColor(ROOT.kBlue) -hh_model_2.SetLineColor(ROOT.kBlue) -hh_model_3.SetLineColor(ROOT.kBlue) -hh_model_4.SetLineColor(ROOT.kBlue) +hh_model_1.SetLineColor("kBlue") +hh_model_2.SetLineColor("kBlue") +hh_model_3.SetLineColor("kBlue") +hh_model_4.SetLineColor("kBlue") # Make canvas and draw ROOT.RooPlots c = ROOT.TCanvas("rf302_utilfuncs", "rf302_utilfuncs", 800, 800) diff --git a/tutorials/roofit/rf305_condcorrprod.py b/tutorials/roofit/rf305_condcorrprod.py index 033d24faed32f..16618c155b3cc 100644 --- a/tutorials/roofit/rf305_condcorrprod.py +++ b/tutorials/roofit/rf305_condcorrprod.py @@ -62,7 +62,7 @@ # Make two-dimensional plot in x vs y hh_model = model.createHistogram("hh_model", x, ROOT.RooFit.Binning(50), ROOT.RooFit.YVar(y, ROOT.RooFit.Binning(50))) -hh_model.SetLineColor(ROOT.kBlue) +hh_model.SetLineColor("kBlue") # Make canvas and draw ROOT.RooPlots c = ROOT.TCanvas("rf305_condcorrprod", "rf05_condcorrprod", 1200, 400) diff --git a/tutorials/roofit/rf306_condpereventerrors.py b/tutorials/roofit/rf306_condpereventerrors.py index 07672002fbf63..9eb5a74367ce4 100644 --- a/tutorials/roofit/rf306_condpereventerrors.py +++ b/tutorials/roofit/rf306_condpereventerrors.py @@ -54,7 +54,7 @@ # Make two-dimensional plot of conditional pdf in (dt,dterr) hh_decay = decay_gm.createHistogram("hh_decay", dt, Binning=50, YVar=dict(var=dterr, Binning=50)) -hh_decay.SetLineColor(ROOT.kBlue) +hh_decay.SetLineColor("kBlue") # Plot decay_gm(dt|dterr) at various values of dterr frame = dt.frame(Title="Slices of decay(dt|dterr) at various dterr") diff --git a/tutorials/roofit/rf307_fullpereventerrors.py b/tutorials/roofit/rf307_fullpereventerrors.py index 83c3c4f620b92..813a6da1d135f 100644 --- a/tutorials/roofit/rf307_fullpereventerrors.py +++ b/tutorials/roofit/rf307_fullpereventerrors.py @@ -67,7 +67,7 @@ # Make two-dimensional plot of conditional pdf in (dt,dterr) hh_model = model.createHistogram("hh_model", dt, Binning=50, YVar=dict(var=dterr, Binning=50)) -hh_model.SetLineColor(ROOT.kBlue) +hh_model.SetLineColor("kBlue") # Make projection of data an dt frame = dt.frame(Title="Projection of model(dt|dterr) on dt") diff --git a/tutorials/roofit/rf308_normintegration2d.py b/tutorials/roofit/rf308_normintegration2d.py index 9df3fd2e1c982..9930624e2a40c 100644 --- a/tutorials/roofit/rf308_normintegration2d.py +++ b/tutorials/roofit/rf308_normintegration2d.py @@ -79,7 +79,7 @@ # Plot cdf of gx versus x hh_cdf = gxy_cdf.createHistogram("hh_cdf", x, Binning=40, YVar=dict(var=y, Binning=40)) -hh_cdf.SetLineColor(ROOT.kBlue) +hh_cdf.SetLineColor("kBlue") c = ROOT.TCanvas("rf308_normintegration2d", "rf308_normintegration2d", 600, 600) ROOT.gPad.SetLeftMargin(0.15) diff --git a/tutorials/roofit/rf309_ndimplot.py b/tutorials/roofit/rf309_ndimplot.py index 06edb68120773..185e0ab57f672 100644 --- a/tutorials/roofit/rf309_ndimplot.py +++ b/tutorials/roofit/rf309_ndimplot.py @@ -42,7 +42,7 @@ # Create and fill ROOT 2D histogram (50x50 bins) with sampling of pdf # hh_pdf = model.createHistogram("hh_model", x, Binning=50, YVar=dict(var=y, Binning=50)) hh_pdf = model.createHistogram("x,y", 50, 50) -hh_pdf.SetLineColor(ROOT.kBlue) +hh_pdf.SetLineColor("kBlue") # Create 3D model and dataset # ----------------------------------------------------- @@ -76,7 +76,7 @@ YVar=dict(var=y, Binning=20), ZVar=dict(var=z, Binning=20), ) -hh_pdf3.SetFillColor(ROOT.kBlue) +hh_pdf3.SetFillColor("kBlue") c1 = ROOT.TCanvas("rf309_2dimplot", "rf309_2dimplot", 800, 800) c1.Divide(2, 2) diff --git a/tutorials/roofit/rf315_projectpdf.py b/tutorials/roofit/rf315_projectpdf.py index 698e0794f477f..9ad7e847692b9 100644 --- a/tutorials/roofit/rf315_projectpdf.py +++ b/tutorials/roofit/rf315_projectpdf.py @@ -67,7 +67,7 @@ # Make 2D histogram of model(x,y) hh = model.createHistogram("x,y") -hh.SetLineColor(ROOT.kBlue) +hh.SetLineColor("kBlue") c = ROOT.TCanvas("rf315_projectpdf", "rf315_projectpdf", 800, 400) c.Divide(2) diff --git a/tutorials/roofit/rf608_fitresultaspdf.py b/tutorials/roofit/rf608_fitresultaspdf.py index 5c1e2f74c95a9..0d272ed0ca88e 100644 --- a/tutorials/roofit/rf608_fitresultaspdf.py +++ b/tutorials/roofit/rf608_fitresultaspdf.py @@ -53,7 +53,7 @@ # Sample a 3-D histogram of the pdf to be visualized as an error # ellipsoid using the GLISO draw option hh_3d = parabPdf.createHistogram("mean,sigma_g2,frac", 25, 25, 25) -hh_3d.SetFillColor(ROOT.kBlue) +hh_3d.SetFillColor("kBlue") # Project 3D parameter pdf down to 3 permutations of two-dimensional pdfs # The integrations corresponding to these projections are performed analytically @@ -66,9 +66,9 @@ hh_sigmag2_frac = pdf_sigmag2_frac.createHistogram("sigma_g2,frac", 50, 50) hh_mean_frac = pdf_mean_frac.createHistogram("mean,frac", 50, 50) hh_mean_sigmag2 = pdf_mean_sigmag2.createHistogram("mean,sigma_g2", 50, 50) -hh_mean_frac.SetLineColor(ROOT.kBlue) -hh_sigmag2_frac.SetLineColor(ROOT.kBlue) -hh_mean_sigmag2.SetLineColor(ROOT.kBlue) +hh_mean_frac.SetLineColor("kBlue") +hh_sigmag2_frac.SetLineColor("kBlue") +hh_mean_sigmag2.SetLineColor("kBlue") # Draw the 'sigar' ROOT.gStyle.SetCanvasPreferGL(True) diff --git a/tutorials/roofit/rf615_simulation_based_inference.py b/tutorials/roofit/rf615_simulation_based_inference.py index a0359e64ee56f..1228cb54501ab 100644 --- a/tutorials/roofit/rf615_simulation_based_inference.py +++ b/tutorials/roofit/rf615_simulation_based_inference.py @@ -228,8 +228,8 @@ def learned_likelihood_ratio(x, mu): frame1.Draw() legend1 = ROOT.TLegend(0.43, 0.63, 0.8, 0.87) -legend1.SetFillColor(ROOT.kWhite) -legend1.SetLineColor(ROOT.kWhite) +legend1.SetFillColor("kWhite") +legend1.SetLineColor("kWhite") legend1.SetTextSize(0.04) legend1.AddEntry("learned", "learned (SBI)", "L") legend1.AddEntry("gauss", "true NLL", "L") @@ -247,8 +247,8 @@ def learned_likelihood_ratio(x, mu): frame2.Draw() legend2 = ROOT.TLegend(0.53, 0.73, 0.87, 0.87) -legend2.SetFillColor(ROOT.kWhite) -legend2.SetLineColor(ROOT.kWhite) +legend2.SetFillColor("kWhite") +legend2.SetLineColor("kWhite") legend2.SetTextSize(0.04) legend2.AddEntry("learned_ratio", "learned (SBI)", "L") legend2.AddEntry("exact", "true ratio", "L") diff --git a/tutorials/roofit/rf617_simulation_based_inference_multidimensional.py b/tutorials/roofit/rf617_simulation_based_inference_multidimensional.py index 0326f336b2298..1a4ad16e7e0b3 100644 --- a/tutorials/roofit/rf617_simulation_based_inference_multidimensional.py +++ b/tutorials/roofit/rf617_simulation_based_inference_multidimensional.py @@ -290,8 +290,8 @@ def learned_likelihood_ratio(*args): frame1.Draw() legend1 = ROOT.TLegend(0.43, 0.63, 0.8, 0.87) -legend1.SetFillColor(ROOT.kWhite) -legend1.SetLineColor(ROOT.kWhite) +legend1.SetFillColor("kWhite") +legend1.SetLineColor("kWhite") legend1.SetTextSize(0.04) legend1.AddEntry("learned", "learned (SBI)", "L") legend1.AddEntry("gauss", "true NLL", "L") @@ -309,8 +309,8 @@ def learned_likelihood_ratio(*args): frame2.Draw() legend2 = ROOT.TLegend(0.53, 0.73, 0.87, 0.87) -legend2.SetFillColor(ROOT.kWhite) -legend2.SetLineColor(ROOT.kWhite) +legend2.SetFillColor("kWhite") +legend2.SetLineColor("kWhite") legend2.SetTextSize(0.04) legend2.AddEntry("learned_ratio", "learned (SBI)", "L") legend2.AddEntry("exact", "true ratio", "L") diff --git a/tutorials/roofit/rf702_efficiencyfit_2D.py b/tutorials/roofit/rf702_efficiencyfit_2D.py index e2a918a8630db..8d73dda4feb03 100644 --- a/tutorials/roofit/rf702_efficiencyfit_2D.py +++ b/tutorials/roofit/rf702_efficiencyfit_2D.py @@ -77,7 +77,7 @@ hh_data_all.SetMinimum(0) hh_data_sel.SetMinimum(0) hh_eff.SetMinimum(0) -hh_eff.SetLineColor(ROOT.kBlue) +hh_eff.SetLineColor("kBlue") # Draw all frames on a canvas ca = ROOT.TCanvas("rf702_efficiency_2D", "rf702_efficiency_2D", 1200, 400) diff --git a/tutorials/roofit/rf704_amplitudefit.py b/tutorials/roofit/rf704_amplitudefit.py index 6a6c1e3bb8092..c8a84cd95ca1c 100644 --- a/tutorials/roofit/rf704_amplitudefit.py +++ b/tutorials/roofit/rf704_amplitudefit.py @@ -55,8 +55,8 @@ # Make 2D plots of amplitudes hh_cos = ampl1.createHistogram("hh_cos", t, Binning=50, YVar=dict(var=cosa, Binning=50)) hh_sin = ampl2.createHistogram("hh_sin", t, Binning=50, YVar=dict(var=cosa, Binning=50)) -hh_cos.SetLineColor(ROOT.kBlue) -hh_sin.SetLineColor(ROOT.kRed) +hh_cos.SetLineColor("kBlue") +hh_sin.SetLineColor("kRed") # Make projection on t, data, and its components # Note component projections may be larger than sum because amplitudes can diff --git a/tutorials/roofit/rf705_linearmorph.py b/tutorials/roofit/rf705_linearmorph.py index 069a3181d4509..3a8b56007d35c 100644 --- a/tutorials/roofit/rf705_linearmorph.py +++ b/tutorials/roofit/rf705_linearmorph.py @@ -74,7 +74,7 @@ # Create 2D histogram hh = lmorph.createHistogram("hh", x, Binning=40, YVar=dict(var=alpha, Binning=40)) -hh.SetLineColor(ROOT.kBlue) +hh.SetLineColor("kBlue") # Fit pdf to dataset with alpha=0.8 # ----------------------------------------------------------------- diff --git a/tutorials/roofit/rf707_kernelestimation.py b/tutorials/roofit/rf707_kernelestimation.py index b2cc164ea0cd2..e4127c44bc924 100644 --- a/tutorials/roofit/rf707_kernelestimation.py +++ b/tutorials/roofit/rf707_kernelestimation.py @@ -80,8 +80,8 @@ # Create histogram of the 2d kernel estimation pdfs hh_pdf = kest4.createHistogram("hh_pdf", x, Binning=25, YVar=dict(var=y, Binning=25)) hh_pdf2 = kest5.createHistogram("hh_pdf2", x, Binning=25, YVar=dict(var=y, Binning=25)) -hh_pdf.SetLineColor(ROOT.kBlue) -hh_pdf2.SetLineColor(ROOT.kMagenta) +hh_pdf.SetLineColor("kBlue") +hh_pdf2.SetLineColor("kMagenta") c = ROOT.TCanvas("rf707_kernelestimation", "rf707_kernelestimation", 800, 800) c.Divide(2, 2) diff --git a/tutorials/roofit/rf710_roopoly.py b/tutorials/roofit/rf710_roopoly.py index d35ce73e155f4..184a529c3efb3 100644 --- a/tutorials/roofit/rf710_roopoly.py +++ b/tutorials/roofit/rf710_roopoly.py @@ -50,8 +50,8 @@ frame.Draw() legend = ROOT.TLegend(0.53, 0.73, 0.86, 0.87) -legend.SetFillColor(ROOT.kWhite) -legend.SetLineColor(ROOT.kWhite) +legend.SetFillColor("kWhite") +legend.SetLineColor("kWhite") legend.SetTextSize(0.02) legend.AddEntry("taylor_o1", "Taylor expansion upto first order", "L") legend.AddEntry("taylor_o2", "Taylor expansion upto second order", "L") diff --git a/tutorials/roofit/rf711_lagrangianmorph.py b/tutorials/roofit/rf711_lagrangianmorph.py index cfb393b72d67f..a3c07abd41680 100644 --- a/tutorials/roofit/rf711_lagrangianmorph.py +++ b/tutorials/roofit/rf711_lagrangianmorph.py @@ -115,8 +115,8 @@ frame0.Draw() leg1 = ROOT.TLegend(0.55, 0.65, 0.94, 0.87) leg1.SetTextSize(0.04) -leg1.SetFillColor(ROOT.kWhite) -leg1.SetLineColor(ROOT.kWhite) +leg1.SetFillColor("kWhite") +leg1.SetLineColor("kWhite") leg1.AddEntry("SM_NPsq0", "SM", "LP") leg1.AddEntry(0, "", "") leg1.AddEntry("cHq3_NPsq1", "c_{Hq^{(3)}}=1.0 at #Lambda^{-2}", "LP") @@ -132,8 +132,8 @@ leg2 = ROOT.TLegend(0.62, 0.65, 0.94, 0.87) leg2.SetTextSize(0.04) -leg2.SetFillColor(ROOT.kWhite) -leg2.SetLineColor(ROOT.kWhite) +leg2.SetFillColor("kWhite") +leg2.SetLineColor("kWhite") leg2.AddEntry("morph_dh_cHq3=0.01", "c_{Hq^{(3)}}=0.01", "L") leg2.AddEntry(0, "", "") @@ -147,7 +147,7 @@ ROOT.gPad.SetLeftMargin(0.12) ROOT.gPad.SetRightMargin(0.18) ROOT.gStyle.SetNumberContours(255) -ROOT.gStyle.SetPalette(ROOT.kGreyScale) +ROOT.gStyle.SetPalette("kGreyScale") ROOT.gStyle.SetOptStat(0) ROOT.TColor.InvertPalette() ROOT.gPad.SetLogz() diff --git a/tutorials/roofit/rf802_mcstudy_addons.py b/tutorials/roofit/rf802_mcstudy_addons.py index 242de50e66277..db129b0254ecd 100644 --- a/tutorials/roofit/rf802_mcstudy_addons.py +++ b/tutorials/roofit/rf802_mcstudy_addons.py @@ -81,8 +81,8 @@ # are calculated by ROOT.RooChiMCSModule hist2_chi2 = mcs2.fitParDataSet().createHistogram("chi2", AutoBinning=nBins) hist2_prob = mcs2.fitParDataSet().createHistogram("prob", AutoBinning=nBins) -hist2_chi2.SetLineColor(ROOT.kRed) -hist2_prob.SetLineColor(ROOT.kRed) +hist2_chi2.SetLineColor("kRed") +hist2_prob.SetLineColor("kRed") c = ROOT.TCanvas("rf802_mcstudy_addons", "rf802_mcstudy_addons", 800, 400) c.Divide(3) diff --git a/tutorials/roostats/IntervalExamples.py b/tutorials/roostats/IntervalExamples.py index d0497576d87a0..cbc65eae22ba7 100644 --- a/tutorials/roostats/IntervalExamples.py +++ b/tutorials/roostats/IntervalExamples.py @@ -134,7 +134,7 @@ # plot the MCMC interval canvas.cd(3) mcPlot = ROOT.RooStats.MCMCIntervalPlot(mcInt) -mcPlot.SetLineColor(ROOT.kGreen) +mcPlot.SetLineColor("kGreen") mcPlot.SetLineWidth(2) mcPlot.Draw() diff --git a/tutorials/roostats/MultivariateGaussianTest.py b/tutorials/roostats/MultivariateGaussianTest.py index e4444a3e1d73d..db49d83d2192e 100644 --- a/tutorials/roostats/MultivariateGaussianTest.py +++ b/tutorials/roostats/MultivariateGaussianTest.py @@ -108,7 +108,7 @@ mcPlot = ROOT.RooStats.MCMCIntervalPlot(mcInt) c1 = ROOT.TCanvas() -mcPlot.SetLineColor(ROOT.kGreen) +mcPlot.SetLineColor("kGreen") mcPlot.SetLineWidth(2) mcPlot.Draw() diff --git a/tutorials/roostats/Zbi_Zgamma.py b/tutorials/roostats/Zbi_Zgamma.py index 2f455e7f7a1cd..623b6b761b2e0 100644 --- a/tutorials/roostats/Zbi_Zgamma.py +++ b/tutorials/roostats/Zbi_Zgamma.py @@ -29,7 +29,7 @@ # plot it, blue is averaged model, red is b known exactly frame = w1["x"].frame() w1["averagedModel"].plotOn(frame) -w1["px"].plotOn(frame, LineColor=ROOT.kRed) +w1["px"].plotOn(frame, LineColor="kRed") frame.Draw() # compare analytic calculation of Z_Bi diff --git a/tutorials/roostats/rs101_limitexample.py b/tutorials/roostats/rs101_limitexample.py index ee470b73804f1..22046cdfccd93 100644 --- a/tutorials/roostats/rs101_limitexample.py +++ b/tutorials/roostats/rs101_limitexample.py @@ -127,15 +127,15 @@ print("FC upper limit on s = ", fcul) fcllLine = ROOT.TLine(fcll, 0, fcll, 1) fculLine = ROOT.TLine(fcul, 0, fcul, 1) - fcllLine.SetLineColor(ROOT.kRed) - fculLine.SetLineColor(ROOT.kRed) + fcllLine.SetLineColor("kRed") + fculLine.SetLineColor("kRed") fcllLine.Draw("same") fculLine.Draw("same") dataCanvas.Update() # Plot MCMC interval and print some statistics mcPlot = ROOT.RooStats.MCMCIntervalPlot(mcInt) -mcPlot.SetLineColor(ROOT.kMagenta) +mcPlot.SetLineColor("kMagenta") mcPlot.SetLineWidth(2) mcPlot.Draw("same") @@ -154,7 +154,7 @@ print("plotting the chain data - nentries = ", chainData.numEntries()) chain = ROOT.RooStats.GetAsTTree("chainTreeData", "chainTreeData", chainData) chain.SetMarkerStyle(6) -chain.SetMarkerColor(ROOT.kRed) +chain.SetMarkerColor("kRed") chain.Draw("s:ratioSigEff:ratioBkgEff", "nll_MarkovChain_local_", "box") # 3-d box proportional to posterior diff --git a/tutorials/roostats/rs401c_FeldmanCousins.py b/tutorials/roostats/rs401c_FeldmanCousins.py index d8b8ccc9668b9..7f20fc22bb64c 100644 --- a/tutorials/roostats/rs401c_FeldmanCousins.py +++ b/tutorials/roostats/rs401c_FeldmanCousins.py @@ -81,9 +81,9 @@ mark = ROOT.TMarker(tmpPoint.getRealValue("mu"), 1, 25) if interval.IsInInterval(tmpPoint): - mark.SetMarkerColor(ROOT.kBlue) + mark.SetMarkerColor("kBlue") else: - mark.SetMarkerColor(ROOT.kRed) + mark.SetMarkerColor("kRed") mark.Draw("s") marks.append(mark) diff --git a/tutorials/roostats/rs_bernsteinCorrection.py b/tutorials/roostats/rs_bernsteinCorrection.py index 443e0c333d12c..c5e69e584585f 100644 --- a/tutorials/roostats/rs_bernsteinCorrection.py +++ b/tutorials/roostats/rs_bernsteinCorrection.py @@ -118,7 +118,7 @@ ) c1.cd(2) - samplingDistExtra.SetLineColor(ROOT.kRed) + samplingDistExtra.SetLineColor("kRed") samplingDistExtra.Draw() samplingDist.Draw("same") diff --git a/tutorials/tmva/TMVA_SOFIE_Inference.py b/tutorials/tmva/TMVA_SOFIE_Inference.py index e658c78939ba3..c9365fabf18b3 100644 --- a/tutorials/tmva/TMVA_SOFIE_Inference.py +++ b/tutorials/tmva/TMVA_SOFIE_Inference.py @@ -90,9 +90,9 @@ c1 = ROOT.TCanvas() ROOT.gStyle.SetOptStat(0) -hs.SetLineColor(ROOT.kRed) +hs.SetLineColor("kRed") hs.Draw() -hb.SetLineColor(ROOT.kBlue) +hb.SetLineColor("kBlue") hb.Draw("SAME") c1.BuildLegend() c1.Draw() diff --git a/tutorials/tmva/TMVA_SOFIE_Models.py b/tutorials/tmva/TMVA_SOFIE_Models.py index 28b6fda7f29b8..a43071072224f 100644 --- a/tutorials/tmva/TMVA_SOFIE_Models.py +++ b/tutorials/tmva/TMVA_SOFIE_Models.py @@ -151,8 +151,8 @@ def EvalModel(session, x) : hb3.Fill(result3) def PlotHistos(hs,hb): - hs.SetLineColor(ROOT.kRed) - hb.SetLineColor(ROOT.kBlue) + hs.SetLineColor("kRed") + hb.SetLineColor("kBlue") hs.Draw() hb.Draw("same") @@ -189,15 +189,15 @@ def MakeROCCurve(hs, hb) : c2 = ROOT.TCanvas() r1,curve1 = MakeROCCurve(hs1,hb1) -curve1.SetLineColor(ROOT.kRed) +curve1.SetLineColor("kRed") curve1.Draw("AC") r2,curve2 = MakeROCCurve(hs2,hb2) -curve2.SetLineColor(ROOT.kBlue) +curve2.SetLineColor("kBlue") curve2.Draw("C") r3,curve3 = MakeROCCurve(hs3,hb3) -curve3.SetLineColor(ROOT.kGreen) +curve3.SetLineColor("kGreen") curve3.Draw("C") c2.Draw() diff --git a/tutorials/tmva/TMVA_SOFIE_RDataFrame.py b/tutorials/tmva/TMVA_SOFIE_RDataFrame.py index dc33c79524974..9971cb2dfc2e7 100644 --- a/tutorials/tmva/TMVA_SOFIE_RDataFrame.py +++ b/tutorials/tmva/TMVA_SOFIE_RDataFrame.py @@ -50,8 +50,8 @@ print("Number of signal entries",h1.GetEntries()) print("Number of background entries",h2.GetEntries()) -h1.SetLineColor(ROOT.kRed) -h2.SetLineColor(ROOT.kBlue) +h1.SetLineColor("kRed") +h2.SetLineColor("kBlue") c1 = ROOT.TCanvas() ROOT.gStyle.SetOptStat(0) diff --git a/tutorials/tmva/tmva102_Testing.py b/tutorials/tmva/tmva102_Testing.py index a18e93c926a80..06579d21e9d1f 100644 --- a/tutorials/tmva/tmva102_Testing.py +++ b/tutorials/tmva/tmva102_Testing.py @@ -41,7 +41,7 @@ g = ROOT.TGraph(len(false_positive_rate), false_positive_rate, true_positive_rate) g.SetTitle("AUC = {:.2f}".format(score)) g.SetLineWidth(3) -g.SetLineColor(ROOT.kRed) +g.SetLineColor("kRed") g.Draw("AC") g.GetXaxis().SetRangeUser(0, 1) g.GetYaxis().SetRangeUser(0, 1)