rootlogon.py
Go to the documentation of this file.
1 
2 # cout << "Loading WCSim Library" << endl
3 # gSystem->Load("libWCSimRoot.so")
4 
5 from ROOT import *
6 from array import *
7 
8 
9 
10 
11 alexStyle = TStyle("alexStyle", "Alex's Style")
12 
13 
14 #set the background color to white
15 alexStyle.SetFillColor(10)
16 alexStyle.SetFrameFillColor(10)
17 alexStyle.SetCanvasColor(10)
18 alexStyle.SetPadColor(10)
19 alexStyle.SetTitleFillColor(0)
20 alexStyle.SetStatColor(10)
21 
22 #dont put a colored frame around the plots
23 alexStyle.SetFrameBorderMode(0)
24 alexStyle.SetCanvasBorderMode(0)
25 alexStyle.SetPadBorderMode(0)
26 
27 #use the primary color palette in heatmap style
28 #alexStyle.SetPalette(1,0)
29 
30 # Set a custom color palette
31 #Int_t colors[50]
32 
33 #Double_t Red[3] = { 0.00, 0.00, 0.00}
34 #Double_t Green[3] = { 0.00, 0.00, 0.00}
35 #Double_t Blue[3] = { 0.70, 1.00, 1.00}
36 #Double_t Length[3] = { 0.00, 1.00, 1.00 }
37 #Int_t FI = TColor::CreateGradientColorTable(2,Length,Red,Green,Blue,50)
38 #for (int i=0 i<50 i++) colors[i] = FI+i
39 #gStyle.SetPalette(50,colors)
40 
41 
42 #navy = (0, 0, 0.5)
43 #cyan = (0, 1, 1)
44 #yellow = (1, 1, 0)
45 #scarlet = (1, 0, 0)
46 
47 #Red = array("d", [navy[0], cyan[0], yellow[0], scarlet[0]])
48 #Green = array("d", [navy[1], cyan[1], yellow[1], scarlet[1]])
49 #Blue = array("d", [navy[2], cyan[2], yellow[2], scarlet[2]])
50 #Length = array("d", [ 0.00, 0.25, 0.55, 1.00])
51 
52 #TColor.CreateGradientColorTable(4,Length,Red,Green,Blue,100)
53 
54 
55 def SetupColors(colors, lens = []):
56  Red = array("d", [c[0] for c in colors] )
57  Green = array("d", [c[1] for c in colors] )
58  Blue = array("d", [c[2] for c in colors] )
59  if not lens: lens = [ float(x)/(len(colors)-1.) for x in range(len(colors)) ]
60  Length = array("d", lens)
61  TColor.CreateGradientColorTable(len(colors),Length,Red,Green,Blue,101)
62 
63 
64 navy = (0, 0, 0.5)
65 blue = (0, 0.2, 1)
66 cyan = (0, 1, 1)
67 yellow = (1, 1, 0)
68 orange = (1, 0.5, 0)
69 magenta = (1, 0, 1)
70 red = (1, 0, 0)
71 white = (1, 1, 1)
72 black = (0, 0, 0)
73 
74 alexStyle.SetNumberContours(101)
75 
76 #colors = [navy, blue, yellow, orange, red]
77 #SetupColors(colors, [0.0, 0.15, 0.5, 0.85, 1.0])
78 SetupColors( [black, red, orange, yellow, white] )
79 
80 
81 #set the default line color for a histogram to be black
82 alexStyle.SetHistLineColor(kBlue)
83 
84 #set the default line color for a fit function to be red
85 alexStyle.SetFuncColor(kRed)
86 
87 #make the axis labels black
88 alexStyle.SetLabelColor(kBlack,"xyz")
89 
90 #set the default title color to be black
91 alexStyle.SetTitleColor(kBlack)
92 
93 
94 # Sizes
95 
96 #set the margins
97 alexStyle.SetPadBottomMargin(0.17)
98 alexStyle.SetPadLeftMargin(0.17)
99 #alexStyle.SetPadTopMargin(0.075)
100 #alexStyle.SetPadLeftMargin(0.15)
101 
102 #set axis label and title text sizes
103 alexStyle.SetLabelSize(0.06,"xyz")
104 alexStyle.SetTitleSize(0.07,"xyz")
105 alexStyle.SetTitleOffset(1.00,"x")
106 alexStyle.SetTitleOffset(1.05,"y")
107 alexStyle.SetStatFontSize(0.04)
108 alexStyle.SetTextSize(0.05)
109 
110 # Cut off number of digits for switch to exponent
111 TGaxis.SetMaxDigits(4)
112 
113 #set the plot title style
114 alexStyle.SetTitleAlign(23)
115 alexStyle.SetTitleX(.5)
116 alexStyle.SetTitleY(0.99)
117 alexStyle.SetTitleBorderSize(0)
118 alexStyle.SetTitleFillColor(0)
119 alexStyle.SetTitleFontSize(0.07)
120 
121 #set the legend style
122 alexStyle.SetLegendBorderSize(0)
123 #alexStyle.SetLegendFillColor(0)
124 
125 #set stat box style
126 alexStyle.SetOptFit(1111)
127 alexStyle.SetOptStat(0000000)
128 alexStyle.SetStatBorderSize(0)
129 
130 #set line widths
131 alexStyle.SetHistLineWidth(2)
132 alexStyle.SetFrameLineWidth(2)
133 alexStyle.SetFuncWidth(2)
134 
135 # Misc
136 
137 #set the number of divisions to show
138 alexStyle.SetNdivisions(506, "xy")
139 
140 #turn off xy grids
141 alexStyle.SetPadGridX(0)
142 alexStyle.SetPadGridY(0)
143 
144 #set the tick mark style
145 alexStyle.SetPadTickX(1)
146 alexStyle.SetPadTickY(1)
147 
148 
149 #marker settings
150 #alexStyle.SetMarkerStyle(8)
151 alexStyle.SetMarkerSize(0.9)
152 alexStyle.SetMarkerStyle(1)
153 alexStyle.SetMarkerSize(1.0)
154 
155 # Fonts
156 
157 kMinosFont = 42
158 alexStyle.SetStatFont(kMinosFont)
159 alexStyle.SetLabelFont(kMinosFont,"xyz")
160 alexStyle.SetTitleFont(kMinosFont,"xyz")
161 alexStyle.SetTextFont(kMinosFont)
162 #alexStyle.SetLegendFont(kMinosFont)
163 
164 #done
165 alexStyle.cd()
166 
167 gROOT.ForceStyle()
168 gStyle.ls()
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 #import os
180 #from ctypes import *
181 #def startWC():
182 # cdll.LoadLibrary(os.path.join(os.environ['HOME'],'WCSim','libWCSimRoot.so'))
183 
184 # History and tab completion
185 
186 #import os
187 #try:
188 # import readline, rlcompleter, atexit
189 #
190 # history_file = os.path.join(os.environ['HOME'], '.python_history')
191 # try:
192 # readline.read_history_file(history_file)
193 # except IOError:
194 # pass
195 # readline.parse_and_bind("tab: complete")
196 # readline.set_history_length(1000)
197 # atexit.register(readline.write_history_file, history_file)
198 #
199 # del readline, rlcompleter, atexit, history_file, __file__
200 #except ImportError:
201 # print "No tab completion"
202 
203 #started = True
def SetupColors(colors, lens=[])
Definition: rootlogon.py:55