1 |
wangdy |
1.1 |
##
|
2 |
wangdy |
1.2 |
## $Log: rootstyle.py,v $
|
3 |
wangdy |
1.4 |
## Revision 1.3 2008/01/18 15:51:18 wangdy
|
4 |
|
|
## adjust top margin of the pad w/(o) title
|
5 |
|
|
##
|
6 |
wangdy |
1.3 |
## Revision 1.2 2008/01/18 11:33:19 wangdy
|
7 |
|
|
## add setting for title color
|
8 |
|
|
##
|
9 |
wangdy |
1.2 |
## Revision 1.1 2008/01/18 10:58:00 wangdy
|
10 |
|
|
## first import several root style related scripts
|
11 |
|
|
##
|
12 |
wangdy |
1.1 |
##
|
13 |
|
|
|
14 |
|
|
""" Dayong's rootlogon file, python version """
|
15 |
|
|
|
16 |
|
|
from ROOT import *
|
17 |
|
|
|
18 |
wangdy |
1.4 |
|
19 |
|
|
atlasStyle=TStyle("atlasStyle","Atlas style")
|
20 |
|
|
tdrStyle = TStyle("tdrStyle","Style for P-TDR")
|
21 |
|
|
ildStyle = TStyle("ildStyle","ILD Style")
|
22 |
|
|
yaStyle = TStyle("yaStyle","Yet Another Style, for talks")
|
23 |
|
|
|
24 |
wangdy |
1.1 |
def atlasstyle():
|
25 |
|
|
|
26 |
|
|
""" ATLAS stylebased on a style file from BaBar"""
|
27 |
|
|
|
28 |
|
|
global atlasStyle
|
29 |
|
|
##.. style from RooLogon.C in workdir
|
30 |
wangdy |
1.3 |
## atlasStyle=TStyle("ATLAS","Atlas style")
|
31 |
wangdy |
1.1 |
|
32 |
|
|
## use plain black on white colors
|
33 |
|
|
icol=0
|
34 |
|
|
atlasStyle.SetFrameBorderMode(icol)
|
35 |
wangdy |
1.4 |
atlasStyle.SetFrameFillColor(icol)
|
36 |
wangdy |
1.1 |
atlasStyle.SetCanvasBorderMode(icol)
|
37 |
|
|
atlasStyle.SetPadBorderMode(icol)
|
38 |
|
|
atlasStyle.SetPadColor(icol)
|
39 |
|
|
atlasStyle.SetCanvasColor(icol)
|
40 |
|
|
atlasStyle.SetStatColor(icol)
|
41 |
|
|
##atlasStyle.SetFillColor(icol)
|
42 |
|
|
|
43 |
|
|
## set the paper & margin sizes
|
44 |
|
|
atlasStyle.SetPaperSize(20,26)
|
45 |
wangdy |
1.3 |
|
46 |
|
|
## with title:0.07 ;no title:0.05
|
47 |
|
|
atlasStyle.SetPadTopMargin(0.07)
|
48 |
wangdy |
1.1 |
atlasStyle.SetPadRightMargin(0.05)
|
49 |
wangdy |
1.3 |
|
50 |
|
|
## with title:0.14 ;no title:0.16
|
51 |
|
|
atlasStyle.SetPadBottomMargin(0.14)
|
52 |
wangdy |
1.1 |
atlasStyle.SetPadLeftMargin(0.12)
|
53 |
|
|
|
54 |
|
|
## use large fonts
|
55 |
|
|
##Int_t font=72
|
56 |
|
|
font=42
|
57 |
|
|
tsize=0.05
|
58 |
|
|
atlasStyle.SetTextFont(font)
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
atlasStyle.SetTextSize(tsize)
|
62 |
|
|
atlasStyle.SetLabelFont(font,"x")
|
63 |
|
|
atlasStyle.SetTitleFont(font,"x")
|
64 |
|
|
atlasStyle.SetLabelFont(font,"y")
|
65 |
|
|
atlasStyle.SetTitleFont(font,"y")
|
66 |
|
|
atlasStyle.SetLabelFont(font,"z")
|
67 |
|
|
atlasStyle.SetTitleFont(font,"z")
|
68 |
|
|
|
69 |
|
|
atlasStyle.SetLabelSize(tsize,"x")
|
70 |
|
|
atlasStyle.SetTitleSize(tsize,"x")
|
71 |
|
|
atlasStyle.SetLabelSize(tsize,"y")
|
72 |
|
|
atlasStyle.SetTitleSize(tsize,"y")
|
73 |
|
|
atlasStyle.SetLabelSize(tsize,"z")
|
74 |
|
|
atlasStyle.SetTitleSize(tsize,"z")
|
75 |
|
|
|
76 |
wangdy |
1.2 |
## dayong add some settings for title
|
77 |
|
|
atlasStyle.SetTitleFillColor(0)
|
78 |
wangdy |
1.1 |
|
79 |
|
|
##use bold lines and markers
|
80 |
|
|
atlasStyle.SetMarkerStyle(20)
|
81 |
|
|
atlasStyle.SetMarkerSize(1.2)
|
82 |
|
|
atlasStyle.SetHistLineWidth(2)
|
83 |
|
|
atlasStyle.SetLineStyleString(2,"[12 12]") ## postscript dashes
|
84 |
|
|
|
85 |
|
|
##get rid of X error bars and y error bar caps
|
86 |
|
|
##atlasStyle.SetErrorX(0.001)
|
87 |
|
|
|
88 |
|
|
##do not display any of the standard histogram decorations
|
89 |
|
|
atlasStyle.SetOptTitle(0)
|
90 |
|
|
##atlasStyle.SetOptStat(1111)
|
91 |
|
|
atlasStyle.SetOptStat(0)
|
92 |
|
|
##atlasStyle.SetOptFit(1111)
|
93 |
|
|
atlasStyle.SetOptFit(0)
|
94 |
|
|
|
95 |
|
|
## put tick marks on top and RHS of plots
|
96 |
|
|
atlasStyle.SetPadTickX(1)
|
97 |
|
|
atlasStyle.SetPadTickY(1)
|
98 |
|
|
gROOT.SetStyle("ATLAS")
|
99 |
|
|
gROOT.ForceStyle()
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
def tdrstyle():
|
103 |
|
|
|
104 |
|
|
"""
|
105 |
|
|
Here is CMS ptdr style
|
106 |
|
|
"""
|
107 |
|
|
global tdrStyle
|
108 |
wangdy |
1.3 |
## tdrStyle = TStyle("tdrStyle","Style for P-TDR")
|
109 |
wangdy |
1.1 |
|
110 |
|
|
## For the canvas:
|
111 |
|
|
tdrStyle.SetCanvasBorderMode(0)
|
112 |
|
|
tdrStyle.SetCanvasColor(kWhite)
|
113 |
|
|
tdrStyle.SetCanvasDefH(600) ##Height of canvas
|
114 |
|
|
tdrStyle.SetCanvasDefW(600) ##Width of canvas
|
115 |
|
|
tdrStyle.SetCanvasDefX(0) ##POsition on screen
|
116 |
|
|
tdrStyle.SetCanvasDefY(0)
|
117 |
|
|
|
118 |
|
|
## For the Pad:
|
119 |
|
|
tdrStyle.SetPadBorderMode(0)
|
120 |
|
|
## tdrStyle.SetPadBorderSize(Width_t size = 1)
|
121 |
|
|
tdrStyle.SetPadColor(kWhite)
|
122 |
|
|
tdrStyle.SetPadGridX(false)
|
123 |
|
|
tdrStyle.SetPadGridY(false)
|
124 |
|
|
tdrStyle.SetGridColor(0)
|
125 |
|
|
tdrStyle.SetGridStyle(3)
|
126 |
|
|
tdrStyle.SetGridWidth(1)
|
127 |
|
|
|
128 |
|
|
## For the frame:
|
129 |
|
|
tdrStyle.SetFrameBorderMode(0)
|
130 |
|
|
tdrStyle.SetFrameBorderSize(1)
|
131 |
|
|
tdrStyle.SetFrameFillColor(0)
|
132 |
|
|
tdrStyle.SetFrameFillStyle(0)
|
133 |
|
|
tdrStyle.SetFrameLineColor(1)
|
134 |
|
|
tdrStyle.SetFrameLineStyle(1)
|
135 |
|
|
tdrStyle.SetFrameLineWidth(1)
|
136 |
|
|
|
137 |
|
|
## For the histo:
|
138 |
|
|
## tdrStyle.SetHistFillColor(1)
|
139 |
|
|
## tdrStyle.SetHistFillStyle(0)
|
140 |
|
|
tdrStyle.SetHistLineColor(1)
|
141 |
|
|
tdrStyle.SetHistLineStyle(0)
|
142 |
|
|
tdrStyle.SetHistLineWidth(1)
|
143 |
|
|
## tdrStyle.SetLegoInnerR(Float_t rad = 0.5)
|
144 |
|
|
## tdrStyle.SetNumberContours(Int_t number = 20)
|
145 |
|
|
tdrStyle.SetEndErrorSize(2)
|
146 |
|
|
tdrStyle.SetMarkerStyle(20)
|
147 |
|
|
tdrStyle.SetErrorX(0.)
|
148 |
|
|
tdrStyle.SetMarkerStyle(20)
|
149 |
|
|
|
150 |
|
|
##For the fit/function:
|
151 |
|
|
tdrStyle.SetOptFit(1)
|
152 |
|
|
tdrStyle.SetFitFormat("5.4g")
|
153 |
|
|
tdrStyle.SetFuncColor(2)
|
154 |
|
|
tdrStyle.SetFuncStyle(1)
|
155 |
|
|
tdrStyle.SetFuncWidth(1)
|
156 |
|
|
|
157 |
|
|
##For the date:
|
158 |
|
|
tdrStyle.SetOptDate(0)
|
159 |
|
|
## tdrStyle.SetDateX(Float_t x = 0.01)
|
160 |
|
|
## tdrStyle.SetDateY(Float_t y = 0.01)
|
161 |
|
|
|
162 |
|
|
## For the statistics box:
|
163 |
|
|
tdrStyle.SetOptFile(0)
|
164 |
|
|
tdrStyle.SetOptStat(0) ## To display the mean and RMS: SetOptStat("mr")
|
165 |
|
|
tdrStyle.SetStatColor(kWhite)
|
166 |
|
|
tdrStyle.SetStatFont(42)
|
167 |
|
|
tdrStyle.SetStatFontSize(0.025)
|
168 |
|
|
tdrStyle.SetStatTextColor(1)
|
169 |
|
|
tdrStyle.SetStatFormat("6.4g")
|
170 |
|
|
tdrStyle.SetStatBorderSize(1)
|
171 |
|
|
tdrStyle.SetStatH(0.1)
|
172 |
|
|
tdrStyle.SetStatW(0.15)
|
173 |
|
|
## tdrStyle.SetStatStyle(Style_t style = 1001)
|
174 |
|
|
## tdrStyle.SetStatX(Float_t x = 0)
|
175 |
|
|
## tdrStyle.SetStatY(Float_t y = 0)
|
176 |
|
|
|
177 |
|
|
## Margins:
|
178 |
|
|
tdrStyle.SetPadTopMargin(0.05)
|
179 |
|
|
tdrStyle.SetPadBottomMargin(0.13)
|
180 |
|
|
tdrStyle.SetPadLeftMargin(0.16)
|
181 |
|
|
tdrStyle.SetPadRightMargin(0.02)
|
182 |
|
|
|
183 |
|
|
## For the Global title:
|
184 |
|
|
tdrStyle.SetOptTitle(0)
|
185 |
|
|
tdrStyle.SetTitleFont(42)
|
186 |
|
|
tdrStyle.SetTitleColor(1)
|
187 |
|
|
tdrStyle.SetTitleTextColor(1)
|
188 |
|
|
tdrStyle.SetTitleFillColor(0)
|
189 |
|
|
tdrStyle.SetTitleFontSize(0.05)
|
190 |
|
|
## tdrStyle.SetTitleH(0) ## Set the height of the title box
|
191 |
|
|
## tdrStyle.SetTitleW(0) ## Set the width of the title box
|
192 |
|
|
## tdrStyle.SetTitleX(0) ## Set the position of the title box
|
193 |
|
|
## tdrStyle.SetTitleY(0.985) ## Set the position of the title box
|
194 |
|
|
## tdrStyle.SetTitleStyle(Style_t style = 1001)
|
195 |
|
|
## tdrStyle.SetTitleBorderSize(2)
|
196 |
|
|
|
197 |
|
|
## For the axis titles:
|
198 |
|
|
tdrStyle.SetTitleColor(1, "XYZ")
|
199 |
|
|
tdrStyle.SetTitleFont(42, "XYZ")
|
200 |
|
|
tdrStyle.SetTitleSize(0.06, "XYZ")
|
201 |
|
|
## tdrStyle.SetTitleXSize(Float_t size = 0.02) ## Another way to set the size?
|
202 |
|
|
## tdrStyle.SetTitleYSize(Float_t size = 0.02)
|
203 |
|
|
tdrStyle.SetTitleXOffset(0.9)
|
204 |
|
|
tdrStyle.SetTitleYOffset(1.25)
|
205 |
|
|
## tdrStyle.SetTitleOffset(1.1, "Y") ## Another way to set the Offset
|
206 |
|
|
|
207 |
|
|
## For the axis labels:
|
208 |
|
|
tdrStyle.SetLabelColor(1, "XYZ")
|
209 |
|
|
tdrStyle.SetLabelFont(42, "XYZ")
|
210 |
|
|
tdrStyle.SetLabelOffset(0.007, "XYZ")
|
211 |
|
|
tdrStyle.SetLabelSize(0.05, "XYZ")
|
212 |
|
|
|
213 |
|
|
## For the axis:
|
214 |
|
|
tdrStyle.SetAxisColor(1, "XYZ")
|
215 |
|
|
tdrStyle.SetStripDecimals(kTRUE)
|
216 |
|
|
tdrStyle.SetTickLength(0.03, "XYZ")
|
217 |
|
|
tdrStyle.SetNdivisions(510, "XYZ")
|
218 |
|
|
tdrStyle.SetPadTickX(1) ## To get tick marks on the opposite side of the frame
|
219 |
|
|
tdrStyle.SetPadTickY(1)
|
220 |
|
|
|
221 |
|
|
## Change for log plots:
|
222 |
|
|
tdrStyle.SetOptLogx(0)
|
223 |
|
|
tdrStyle.SetOptLogy(0)
|
224 |
|
|
tdrStyle.SetOptLogz(0)
|
225 |
|
|
|
226 |
|
|
## Postscript options:
|
227 |
|
|
## tdrStyle.SetPaperSize(20.,20.)
|
228 |
|
|
## tdrStyle.SetLineScalePS(Float_t scale = 3)
|
229 |
|
|
## tdrStyle.SetLineStyleString(Int_t i, const char* text)
|
230 |
|
|
## tdrStyle.SetHeaderPS(const char* header)
|
231 |
|
|
## tdrStyle.SetTitlePS(const char* pstitle)
|
232 |
|
|
|
233 |
|
|
## tdrStyle.SetBarOffset(Float_t baroff = 0.5)
|
234 |
|
|
## tdrStyle.SetBarWidth(Float_t barwidth = 0.5)
|
235 |
|
|
## tdrStyle.SetPaintTextFormat(const char* format = "g")
|
236 |
|
|
## tdrStyle.SetPalette(Int_t ncolors = 0, Int_t* colors = 0)
|
237 |
|
|
## tdrStyle.SetTimeOffset(Double_t toffset)
|
238 |
|
|
## tdrStyle.SetHistMinimumZero(kTRUE)
|
239 |
|
|
gROOT.SetStyle("tdrStyle")
|
240 |
|
|
gROOT.ForceStyle()
|
241 |
|
|
|
242 |
wangdy |
1.4 |
def ildstyle():
|
243 |
|
|
|
244 |
|
|
"""
|
245 |
|
|
Here is ILD style
|
246 |
|
|
"""
|
247 |
|
|
global ildStyle
|
248 |
|
|
|
249 |
|
|
|
250 |
|
|
#set the background color to white
|
251 |
|
|
ildStyle.SetFillColor(10)
|
252 |
|
|
ildStyle.SetFrameFillColor(10)
|
253 |
|
|
ildStyle.SetCanvasColor(10)
|
254 |
|
|
ildStyle.SetPadColor(10)
|
255 |
|
|
ildStyle.SetTitleFillColor(0)
|
256 |
|
|
ildStyle.SetStatColor(10)
|
257 |
|
|
|
258 |
|
|
#dont put a colored frame around the plots
|
259 |
|
|
ildStyle.SetFrameBorderMode(0)
|
260 |
|
|
ildStyle.SetCanvasBorderMode(0)
|
261 |
|
|
ildStyle.SetPadBorderMode(0)
|
262 |
|
|
ildStyle.SetLegendBorderSize(0)
|
263 |
|
|
|
264 |
|
|
#use the primary color palette
|
265 |
|
|
ildStyle.SetPalette(1,0)
|
266 |
|
|
|
267 |
|
|
#set the default line color for a histogram to be black
|
268 |
|
|
ildStyle.SetHistLineColor(kBlack)
|
269 |
|
|
|
270 |
|
|
#set the default line color for a fit function to be red
|
271 |
|
|
ildStyle.SetFuncColor(kRed)
|
272 |
|
|
|
273 |
|
|
#make the axis labels black
|
274 |
|
|
ildStyle.SetLabelColor(kBlack,"xyz")
|
275 |
|
|
|
276 |
|
|
#set the default title color to be black
|
277 |
|
|
ildStyle.SetTitleColor(kBlack)
|
278 |
|
|
|
279 |
|
|
#set the margins
|
280 |
|
|
ildStyle.SetPadBottomMargin(0.18)
|
281 |
|
|
ildStyle.SetPadTopMargin(0.08)
|
282 |
|
|
ildStyle.SetPadRightMargin(0.08)
|
283 |
|
|
ildStyle.SetPadLeftMargin(0.17)
|
284 |
|
|
|
285 |
|
|
#set axis label and title text sizes
|
286 |
|
|
ildStyle.SetLabelFont(42,"xyz")
|
287 |
|
|
ildStyle.SetLabelSize(0.06,"xyz")
|
288 |
|
|
ildStyle.SetLabelOffset(0.015,"xyz")
|
289 |
|
|
ildStyle.SetTitleFont(42,"xyz")
|
290 |
|
|
ildStyle.SetTitleSize(0.07,"xyz")
|
291 |
|
|
ildStyle.SetTitleOffset(1.1,"yz")
|
292 |
|
|
ildStyle.SetTitleOffset(1.0,"x")
|
293 |
|
|
ildStyle.SetStatFont(42)
|
294 |
|
|
ildStyle.SetStatFontSize(0.07)
|
295 |
|
|
ildStyle.SetTitleBorderSize(0)
|
296 |
|
|
ildStyle.SetStatBorderSize(0)
|
297 |
|
|
ildStyle.SetTextFont(42)
|
298 |
|
|
|
299 |
|
|
#set line widths
|
300 |
|
|
ildStyle.SetFrameLineWidth(2)
|
301 |
|
|
ildStyle.SetFuncWidth(2)
|
302 |
|
|
ildStyle.SetHistLineWidth(2)
|
303 |
|
|
|
304 |
|
|
#set the number of divisions to show
|
305 |
|
|
ildStyle.SetNdivisions(506, "xy")
|
306 |
|
|
|
307 |
|
|
#turn off xy grids
|
308 |
|
|
ildStyle.SetPadGridX(0)
|
309 |
|
|
ildStyle.SetPadGridY(0)
|
310 |
|
|
|
311 |
|
|
#set the tick mark style
|
312 |
|
|
ildStyle.SetPadTickX(1)
|
313 |
|
|
ildStyle.SetPadTickY(1)
|
314 |
|
|
|
315 |
|
|
#turn off stats
|
316 |
|
|
ildStyle.SetOptStat(0)
|
317 |
|
|
ildStyle.SetOptFit(0)
|
318 |
|
|
|
319 |
|
|
#marker settings
|
320 |
|
|
ildStyle.SetMarkerStyle(20)
|
321 |
|
|
ildStyle.SetMarkerSize(0.7)
|
322 |
|
|
ildStyle.SetLineWidth(2)
|
323 |
|
|
|
324 |
|
|
gROOT.SetStyle("ildStyle")
|
325 |
|
|
gROOT.ForceStyle()
|
326 |
|
|
|
327 |
|
|
def yastyle():
|
328 |
|
|
|
329 |
|
|
"""
|
330 |
|
|
Here is Yet Another style
|
331 |
|
|
"""
|
332 |
|
|
global yaStyle
|
333 |
|
|
|
334 |
|
|
yaStyle.SetFillColor(0)
|
335 |
|
|
yaStyle.SetOptDate()
|
336 |
|
|
yaStyle.SetOptStat(111110)
|
337 |
|
|
yaStyle.SetOptFit(1111)
|
338 |
|
|
yaStyle.SetPadTickX(1)
|
339 |
|
|
yaStyle.SetPadTickY(1)
|
340 |
|
|
yaStyle.SetMarkerSize(0.5)
|
341 |
|
|
yaStyle.SetMarkerStyle(8)
|
342 |
|
|
yaStyle.SetGridStyle(3)
|
343 |
|
|
yaStyle.SetPaperSize(TStyle::kA4)
|
344 |
|
|
yaStyle.SetStatW(0.35) # width of statistics box; default is 0.19
|
345 |
|
|
yaStyle.SetStatH(0.20) # height of statistics box; default is 0.1
|
346 |
|
|
yaStyle.SetStatFormat("6.4g") # leave default format for now
|
347 |
|
|
yaStyle.SetTitleSize(0.055, "") # size for pad title; default is 0.02
|
348 |
|
|
# Really big; useful for talks.
|
349 |
|
|
yaStyle.SetTitleSize(0.1, "") # size for pad title; default is 0.02
|
350 |
|
|
yaStyle.SetLabelSize(0.05, "XYZ") # size for axis labels; default is 0.04
|
351 |
|
|
yaStyle.SetStatFontSize(0.06) # size for stat. box
|
352 |
|
|
yaStyle.SetTitleFont(32, "XYZ") # times-bold-italic font (p. 153) for axes
|
353 |
|
|
yaStyle.SetTitleFont(32, "") # same for pad title
|
354 |
|
|
yaStyle.SetLabelFont(32, "XYZ") # same for axis labels
|
355 |
|
|
yaStyle.SetStatFont(32) # same for stat. box
|
356 |
|
|
yaStyle.SetLabelOffset(0.006, "Y") # default is 0.005
|
357 |
|
|
|
358 |
|
|
gROOT.SetStyle("yaStyle")
|
359 |
|
|
gROOT.ForceStyle()
|
360 |
|
|
|
361 |
wangdy |
1.1 |
if __name__ == '__main__':
|
362 |
wangdy |
1.3 |
## default style
|
363 |
wangdy |
1.1 |
gROOT.SetStyle("Plain")
|
364 |
|
|
gStyle.SetOptStat(1111111)
|
365 |
|
|
gStyle.SetPadTickX(1)
|
366 |
|
|
gStyle.SetPadTickY(1)
|
367 |
|
|
|
368 |
wangdy |
1.4 |
## activate these two style following way: better way
|
369 |
|
|
# atlasstyle()
|
370 |
|
|
# tdrstyle()
|
371 |
|
|
# ildstyle()
|
372 |
|
|
# yastyle()
|
373 |
|
|
|
374 |
wangdy |
1.1 |
## activate these two style following way
|
375 |
wangdy |
1.4 |
## gROOT.SetStyle("atlasStyle")
|
376 |
wangdy |
1.1 |
## gROOT.SetStyle("tdrStyle")
|
377 |
wangdy |
1.4 |
## gROOT.SetStyle("ildStyle")
|
378 |
|
|
## gROOT.SetStyle("yaStyle")
|
379 |
wangdy |
1.1 |
## gROOT.ForceStyle()
|
380 |
|
|
|
381 |
|
|
|
382 |
|
|
|