CMS 3D CMS Logo

style.py
Go to the documentation of this file.
1 
5 
6 import ROOT
7 ROOT.PyConfig.IgnoreCommandLineOptions = True
8 ROOT.gROOT.SetBatch()
9 
10 
11 
14 
15 
16 def identification(config):
17  text = ROOT.TPaveText(0.0, 0.95, 1.0, 1.0, "blNDC")
18  text.AddText(config.message)
19  text.SetBorderSize(0)
20  text.SetTextAlign(12)
21  text.SetTextSizePixels(10)
22  text.SetTextFont(82)
23  text.SetFillColor(0)
24  return text
25 
26 
29 
30 
31 def setstatsize(canvas, plot, config):
32  # statistics size
33  ROOT.gStyle.SetStatW(0.3)
34  ROOT.gStyle.SetStatH(0.3)
35  plot.Draw()
36  canvas.Update()
37 
38  # set the size of the statistics box
39  stat = plot.FindObject("stats")
40  stat.SetX1NDC(1 - config.statboxsize)
41  stat.SetY1NDC(1 - config.statboxsize)
42 
43 
44 
48 
49 
50 def setgstyle():
51  # Zero horizontal error bars
52  ROOT.gStyle.SetErrorX(0)
53 
54  # For the canvas
55  ROOT.gStyle.SetCanvasBorderMode(0)
56  ROOT.gStyle.SetCanvasColor(0)
57  ROOT.gStyle.SetCanvasDefH(800) # Height of canvas
58  ROOT.gStyle.SetCanvasDefW(800) # Width of canvas
59  ROOT.gStyle.SetCanvasDefX(0) # Position on screen
60  ROOT.gStyle.SetCanvasDefY(0)
61 
62  # For the frame
63  ROOT.gStyle.SetFrameBorderMode(0)
64  ROOT.gStyle.SetFrameBorderSize(1)
65  ROOT.gStyle.SetFrameFillColor(1)
66  ROOT.gStyle.SetFrameFillStyle(0)
67  ROOT.gStyle.SetFrameLineColor(1)
68  ROOT.gStyle.SetFrameLineStyle(0)
69  ROOT.gStyle.SetFrameLineWidth(1)
70 
71  # For the Pad
72  ROOT.gStyle.SetPadBorderMode(0)
73  ROOT.gStyle.SetPadColor(0)
74  ROOT.gStyle.SetPadGridX(False)
75  ROOT.gStyle.SetPadGridY(False)
76  ROOT.gStyle.SetGridColor(0)
77  ROOT.gStyle.SetGridStyle(3)
78  ROOT.gStyle.SetGridWidth(1)
79 
80  # Margins
81  ROOT.gStyle.SetPadTopMargin(0.08)
82  ROOT.gStyle.SetPadBottomMargin(0.19)
83  ROOT.gStyle.SetPadLeftMargin(0.17)
84  #ROOT.gStyle.SetPadRightMargin(0.07)
85 
86  # For the histo:
87  ROOT.gStyle.SetHistLineColor(1)
88  ROOT.gStyle.SetHistLineStyle(0)
89  ROOT.gStyle.SetHistLineWidth(2)
90  ROOT.gStyle.SetMarkerSize(1.4)
91  ROOT.gStyle.SetEndErrorSize(4)
92 
93  # For the statistics box:
94  ROOT.gStyle.SetOptStat(0)
95 
96  # For the axis
97  ROOT.gStyle.SetAxisColor(1, "XYZ")
98  ROOT.gStyle.SetTickLength(0.03, "XYZ")
99  ROOT.gStyle.SetNdivisions(510, "XYZ")
100  ROOT.gStyle.SetPadTickX(1)
101  ROOT.gStyle.SetPadTickY(1)
102  ROOT.gStyle.SetStripDecimals(False)
103 
104  # For the axis labels and titles
105  ROOT.gStyle.SetTitleColor(1, "XYZ")
106  ROOT.gStyle.SetLabelColor(1, "XYZ")
107  ROOT.gStyle.SetLabelFont(42, "XYZ")
108  ROOT.gStyle.SetLabelOffset(0.007, "XYZ")
109  ROOT.gStyle.SetLabelSize(0.045, "XYZ")
110  ROOT.gStyle.SetTitleFont(42, "XYZ")
111  ROOT.gStyle.SetTitleSize(0.06, "XYZ")
112 
113  # For the legend
114  ROOT.gStyle.SetLegendBorderSize(0)
def setstatsize(canvas, plot, config)
statistics size
Definition: style.py:31
def identification(config)
creates the identification text in the top left corner
Definition: style.py:16
def setgstyle()
set gstyle by https://github.com/mschrode/AwesomePlots/blob/master/Style.cc
Definition: style.py:50