CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
style.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 ##########################################################################
4 ##
5 # Set the style of the output
6 ##
7 
8 from ROOT import TPaveText, gStyle
9 
10 
11 ######################################################################
12 # creates the identification text in the top left corner
13 #
14 
15 
16 def identification(config):
17  text = 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 ######################################################################
27 # statistics size
28 #
29 
30 
31 def setstatsize(canvas, plot, config):
32  # statistics size
33  gStyle.SetStatW(0.3)
34  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 ######################################################################
45 # set gstyle
46 # by https://github.com/mschrode/AwesomePlots/blob/master/Style.cc
47 #
48 
49 
50 def setgstyle():
51  # Zero horizontal error bars
52  gStyle.SetErrorX(0)
53 
54  # For the canvas
55  gStyle.SetCanvasBorderMode(0)
56  gStyle.SetCanvasColor(0)
57  gStyle.SetCanvasDefH(800) # Height of canvas
58  gStyle.SetCanvasDefW(800) # Width of canvas
59  gStyle.SetCanvasDefX(0) # Position on screen
60  gStyle.SetCanvasDefY(0)
61 
62  # For the frame
63  gStyle.SetFrameBorderMode(0)
64  gStyle.SetFrameBorderSize(1)
65  gStyle.SetFrameFillColor(1)
66  gStyle.SetFrameFillStyle(0)
67  gStyle.SetFrameLineColor(1)
68  gStyle.SetFrameLineStyle(0)
69  gStyle.SetFrameLineWidth(1)
70 
71  # For the Pad
72  gStyle.SetPadBorderMode(0)
73  gStyle.SetPadColor(0)
74  gStyle.SetPadGridX(False)
75  gStyle.SetPadGridY(False)
76  gStyle.SetGridColor(0)
77  gStyle.SetGridStyle(3)
78  gStyle.SetGridWidth(1)
79 
80  # Margins
81  gStyle.SetPadTopMargin(0.08)
82  gStyle.SetPadBottomMargin(0.19)
83  gStyle.SetPadLeftMargin(0.17)
84  #gStyle.SetPadRightMargin(0.07)
85 
86  # For the histo:
87  gStyle.SetHistLineColor(1)
88  gStyle.SetHistLineStyle(0)
89  gStyle.SetHistLineWidth(2)
90  gStyle.SetMarkerSize(1.4)
91  gStyle.SetEndErrorSize(4)
92 
93  # For the statistics box:
94  gStyle.SetOptStat(0)
95 
96  # For the axis
97  gStyle.SetAxisColor(1, "XYZ")
98  gStyle.SetTickLength(0.03, "XYZ")
99  gStyle.SetNdivisions(510, "XYZ")
100  gStyle.SetPadTickX(1)
101  gStyle.SetPadTickY(1)
102  gStyle.SetStripDecimals(False)
103 
104  # For the axis labels and titles
105  gStyle.SetTitleColor(1, "XYZ")
106  gStyle.SetLabelColor(1, "XYZ")
107  gStyle.SetLabelFont(42, "XYZ")
108  gStyle.SetLabelOffset(0.007, "XYZ")
109  gStyle.SetLabelSize(0.045, "XYZ")
110  gStyle.SetTitleFont(42, "XYZ")
111  gStyle.SetTitleSize(0.06, "XYZ")
112 
113  # For the legend
114  gStyle.SetLegendBorderSize(0)
def setgstyle
set gstyle by https://github.com/mschrode/AwesomePlots/blob/master/Style.cc
Definition: style.py:50
def identification
creates the identification text in the top left corner
Definition: style.py:16
def setstatsize
statistics size
Definition: style.py:31