1 |
|
## |
2 |
|
## $Log$ |
3 |
+ |
## Revision 1.6 2010/05/18 17:20:12 wangdy |
4 |
+ |
## small updates |
5 |
+ |
## |
6 |
+ |
## Revision 1.5 2009/06/30 08:59:19 wangdy |
7 |
+ |
## add mitstyle and some style functions |
8 |
+ |
## |
9 |
+ |
## Revision 1.4 2009/06/26 10:13:31 wangdy |
10 |
+ |
## first import ildstyle; add yastyle and ildstyle directly into root logon |
11 |
+ |
## |
12 |
|
## Revision 1.3 2008/01/18 15:51:18 wangdy |
13 |
|
## adjust top margin of the pad w/(o) title |
14 |
|
## |
24 |
|
|
25 |
|
from ROOT import * |
26 |
|
|
27 |
+ |
|
28 |
+ |
atlasStyle=TStyle("atlasStyle","Atlas style") |
29 |
+ |
tdrStyle = TStyle("tdrStyle","Style for P-TDR") |
30 |
+ |
ildStyle = TStyle("ildStyle","ILD Style") |
31 |
+ |
yaStyle = TStyle("yaStyle","Yet Another Style, for talks") |
32 |
+ |
MITStyle = TStyle("mitStyle","The Perfect Style for Plots ;-)"); |
33 |
+ |
|
34 |
+ |
|
35 |
|
def atlasstyle(): |
36 |
|
|
37 |
|
""" ATLAS stylebased on a style file from BaBar""" |
38 |
|
|
39 |
|
global atlasStyle |
40 |
|
##.. style from RooLogon.C in workdir |
24 |
– |
## atlasStyle=TStyle("ATLAS","Atlas style") |
41 |
|
|
42 |
|
## use plain black on white colors |
43 |
|
icol=0 |
44 |
|
atlasStyle.SetFrameBorderMode(icol) |
45 |
+ |
atlasStyle.SetFrameFillColor(icol) |
46 |
|
atlasStyle.SetCanvasBorderMode(icol) |
47 |
|
atlasStyle.SetPadBorderMode(icol) |
48 |
|
atlasStyle.SetPadColor(icol) |
55 |
|
|
56 |
|
## with title:0.07 ;no title:0.05 |
57 |
|
atlasStyle.SetPadTopMargin(0.07) |
58 |
< |
atlasStyle.SetPadRightMargin(0.05) |
58 |
> |
atlasStyle.SetPadRightMargin(0.10) |
59 |
|
|
60 |
|
## with title:0.14 ;no title:0.16 |
61 |
|
atlasStyle.SetPadBottomMargin(0.14) |
102 |
|
##atlasStyle.SetOptFit(1111) |
103 |
|
atlasStyle.SetOptFit(0) |
104 |
|
|
105 |
+ |
atlasStyle.SetPalette(1); |
106 |
|
## put tick marks on top and RHS of plots |
107 |
|
atlasStyle.SetPadTickX(1) |
108 |
|
atlasStyle.SetPadTickY(1) |
109 |
< |
gROOT.SetStyle("ATLAS") |
109 |
> |
gROOT.SetStyle("atlasStyle") |
110 |
|
gROOT.ForceStyle() |
111 |
|
|
112 |
|
|
187 |
|
|
188 |
|
## Margins: |
189 |
|
tdrStyle.SetPadTopMargin(0.05) |
190 |
< |
tdrStyle.SetPadBottomMargin(0.13) |
191 |
< |
tdrStyle.SetPadLeftMargin(0.16) |
192 |
< |
tdrStyle.SetPadRightMargin(0.02) |
190 |
> |
tdrStyle.SetPadBottomMargin(0.15) |
191 |
> |
tdrStyle.SetPadLeftMargin(0.15) |
192 |
> |
tdrStyle.SetPadRightMargin(0.06) |
193 |
|
|
194 |
|
## For the Global title: |
195 |
|
tdrStyle.SetOptTitle(0) |
228 |
|
tdrStyle.SetNdivisions(510, "XYZ") |
229 |
|
tdrStyle.SetPadTickX(1) ## To get tick marks on the opposite side of the frame |
230 |
|
tdrStyle.SetPadTickY(1) |
231 |
+ |
|
232 |
+ |
## for the palette: |
233 |
+ |
tdrStyle.SetPalette(1); |
234 |
+ |
## tdrStyle.SetNumberContours(8); |
235 |
|
|
236 |
|
## Change for log plots: |
237 |
|
tdrStyle.SetOptLogx(0) |
254 |
|
gROOT.SetStyle("tdrStyle") |
255 |
|
gROOT.ForceStyle() |
256 |
|
|
257 |
< |
atlasStyle=TStyle("ATLAS","Atlas style") |
258 |
< |
tdrStyle = TStyle("tdrStyle","Style for P-TDR") |
257 |
> |
def ildstyle(): |
258 |
> |
|
259 |
> |
""" |
260 |
> |
Here is ILD style |
261 |
> |
""" |
262 |
> |
global ildStyle |
263 |
> |
|
264 |
> |
|
265 |
> |
#set the background color to white |
266 |
> |
ildStyle.SetFillColor(10) |
267 |
> |
ildStyle.SetFrameFillColor(10) |
268 |
> |
ildStyle.SetCanvasColor(10) |
269 |
> |
ildStyle.SetPadColor(10) |
270 |
> |
ildStyle.SetTitleFillColor(0) |
271 |
> |
ildStyle.SetStatColor(10) |
272 |
> |
|
273 |
> |
#dont put a colored frame around the plots |
274 |
> |
ildStyle.SetFrameBorderMode(0) |
275 |
> |
ildStyle.SetCanvasBorderMode(0) |
276 |
> |
ildStyle.SetPadBorderMode(0) |
277 |
> |
ildStyle.SetLegendBorderSize(0) |
278 |
> |
|
279 |
> |
#use the primary color palette |
280 |
> |
ildStyle.SetPalette(1) |
281 |
> |
|
282 |
> |
#set the default line color for a histogram to be black |
283 |
> |
ildStyle.SetHistLineColor(kBlack) |
284 |
> |
|
285 |
> |
#set the default line color for a fit function to be red |
286 |
> |
ildStyle.SetFuncColor(kRed) |
287 |
> |
|
288 |
> |
#make the axis labels black |
289 |
> |
ildStyle.SetLabelColor(kBlack,"xyz") |
290 |
> |
|
291 |
> |
#set the default title color to be black |
292 |
> |
ildStyle.SetTitleColor(kBlack) |
293 |
> |
|
294 |
> |
#set the margins |
295 |
> |
ildStyle.SetPadBottomMargin(0.18) |
296 |
> |
ildStyle.SetPadTopMargin(0.08) |
297 |
> |
ildStyle.SetPadRightMargin(0.08) |
298 |
> |
ildStyle.SetPadLeftMargin(0.17) |
299 |
> |
|
300 |
> |
#set axis label and title text sizes |
301 |
> |
ildStyle.SetLabelFont(42,"xyz") |
302 |
> |
ildStyle.SetLabelSize(0.06,"xyz") |
303 |
> |
ildStyle.SetLabelOffset(0.015,"xyz") |
304 |
> |
ildStyle.SetTitleFont(42,"xyz") |
305 |
> |
ildStyle.SetTitleSize(0.07,"xyz") |
306 |
> |
ildStyle.SetTitleOffset(1.1,"yz") |
307 |
> |
ildStyle.SetTitleOffset(1.0,"x") |
308 |
> |
ildStyle.SetStatFont(42) |
309 |
> |
ildStyle.SetStatFontSize(0.07) |
310 |
> |
ildStyle.SetTitleBorderSize(0) |
311 |
> |
ildStyle.SetStatBorderSize(0) |
312 |
> |
ildStyle.SetTextFont(42) |
313 |
> |
|
314 |
> |
#set line widths |
315 |
> |
ildStyle.SetFrameLineWidth(2) |
316 |
> |
ildStyle.SetFuncWidth(2) |
317 |
> |
ildStyle.SetHistLineWidth(2) |
318 |
> |
|
319 |
> |
#set the number of divisions to show |
320 |
> |
ildStyle.SetNdivisions(506, "xy") |
321 |
> |
|
322 |
> |
#turn off xy grids |
323 |
> |
ildStyle.SetPadGridX(0) |
324 |
> |
ildStyle.SetPadGridY(0) |
325 |
> |
|
326 |
> |
#set the tick mark style |
327 |
> |
ildStyle.SetPadTickX(1) |
328 |
> |
ildStyle.SetPadTickY(1) |
329 |
> |
|
330 |
> |
#turn off stats |
331 |
> |
ildStyle.SetOptStat(0) |
332 |
> |
ildStyle.SetOptFit(0) |
333 |
> |
|
334 |
> |
#marker settings |
335 |
> |
ildStyle.SetMarkerStyle(20) |
336 |
> |
ildStyle.SetMarkerSize(0.7) |
337 |
> |
ildStyle.SetLineWidth(2) |
338 |
> |
|
339 |
> |
gROOT.SetStyle("ildStyle") |
340 |
> |
gROOT.ForceStyle() |
341 |
> |
|
342 |
> |
def yastyle(): |
343 |
> |
|
344 |
> |
""" |
345 |
> |
Here is Yet Another style |
346 |
> |
""" |
347 |
> |
global yaStyle |
348 |
> |
|
349 |
> |
yaStyle.SetFillColor(0) |
350 |
> |
yaStyle.SetOptDate() |
351 |
> |
yaStyle.SetOptStat(111110) |
352 |
> |
yaStyle.SetOptFit(1111) |
353 |
> |
yaStyle.SetPadTickX(1) |
354 |
> |
yaStyle.SetPadTickY(1) |
355 |
> |
yaStyle.SetMarkerSize(0.5) |
356 |
> |
yaStyle.SetMarkerStyle(8) |
357 |
> |
yaStyle.SetGridStyle(3) |
358 |
> |
yaStyle.SetPaperSize(kA4) |
359 |
> |
yaStyle.SetStatW(0.35) # width of statistics box; default is 0.19 |
360 |
> |
yaStyle.SetStatH(0.20) # height of statistics box; default is 0.1 |
361 |
> |
yaStyle.SetStatFormat("6.4g") # leave default format for now |
362 |
> |
yaStyle.SetTitleSize(0.055, "") # size for pad title; default is 0.02 |
363 |
> |
# Really big; useful for talks. |
364 |
> |
yaStyle.SetTitleSize(0.1, "") # size for pad title; default is 0.02 |
365 |
> |
yaStyle.SetLabelSize(0.05, "XYZ") # size for axis labels; default is 0.04 |
366 |
> |
yaStyle.SetStatFontSize(0.06) # size for stat. box |
367 |
> |
yaStyle.SetTitleFont(32, "XYZ") # times-bold-italic font (p. 153) for axes |
368 |
> |
yaStyle.SetTitleFont(32, "") # same for pad title |
369 |
> |
yaStyle.SetLabelFont(32, "XYZ") # same for axis labels |
370 |
> |
yaStyle.SetStatFont(32) # same for stat. box |
371 |
> |
yaStyle.SetLabelOffset(0.006, "Y") # default is 0.005 |
372 |
> |
|
373 |
> |
gROOT.SetStyle("yaStyle") |
374 |
> |
gROOT.ForceStyle() |
375 |
> |
|
376 |
> |
def mitstyle(): |
377 |
> |
global MITStyle |
378 |
> |
# Canvas |
379 |
> |
MITStyle.SetCanvasColor (0) |
380 |
> |
MITStyle.SetCanvasBorderSize(10) |
381 |
> |
MITStyle.SetCanvasBorderMode(0) |
382 |
> |
MITStyle.SetCanvasDefH (700) |
383 |
> |
MITStyle.SetCanvasDefW (700) |
384 |
> |
MITStyle.SetCanvasDefX (100) |
385 |
> |
MITStyle.SetCanvasDefY (100) |
386 |
> |
|
387 |
> |
# Pads |
388 |
> |
MITStyle.SetPadColor (0) |
389 |
> |
MITStyle.SetPadBorderSize (10) |
390 |
> |
MITStyle.SetPadBorderMode (0) |
391 |
> |
MITStyle.SetPadBottomMargin(0.13) |
392 |
> |
MITStyle.SetPadTopMargin (0.08) |
393 |
> |
MITStyle.SetPadLeftMargin (0.15) |
394 |
> |
MITStyle.SetPadRightMargin (0.05) |
395 |
> |
MITStyle.SetPadGridX (0) |
396 |
> |
MITStyle.SetPadGridY (0) |
397 |
> |
MITStyle.SetPadTickX (0) |
398 |
> |
MITStyle.SetPadTickY (0) |
399 |
> |
|
400 |
> |
# Frames |
401 |
> |
MITStyle.SetFrameFillStyle ( 0) |
402 |
> |
MITStyle.SetFrameFillColor ( 0) |
403 |
> |
MITStyle.SetFrameLineColor ( 1) |
404 |
> |
MITStyle.SetFrameLineStyle ( 0) |
405 |
> |
MITStyle.SetFrameLineWidth ( 1) |
406 |
> |
MITStyle.SetFrameBorderSize(10) |
407 |
> |
MITStyle.SetFrameBorderMode( 0) |
408 |
> |
|
409 |
> |
# Histograms |
410 |
> |
MITStyle.SetHistFillColor(2) |
411 |
> |
MITStyle.SetHistFillStyle(0) |
412 |
> |
MITStyle.SetHistLineColor(1) |
413 |
> |
MITStyle.SetHistLineStyle(0) |
414 |
> |
MITStyle.SetHistLineWidth(2) |
415 |
> |
MITStyle.SetNdivisions(505) |
416 |
> |
|
417 |
> |
# Functions |
418 |
> |
MITStyle.SetFuncColor(1) |
419 |
> |
MITStyle.SetFuncStyle(0) |
420 |
> |
MITStyle.SetFuncWidth(2) |
421 |
> |
|
422 |
> |
# Various |
423 |
> |
MITStyle.SetMarkerStyle(20) |
424 |
> |
MITStyle.SetMarkerColor(kBlack) |
425 |
> |
MITStyle.SetMarkerSize (1.2) |
426 |
> |
|
427 |
> |
MITStyle.SetTitleSize (0.055,"X") |
428 |
> |
MITStyle.SetTitleOffset(0.900,"X") |
429 |
> |
MITStyle.SetLabelOffset(0.005,"X") |
430 |
> |
MITStyle.SetLabelSize (0.050,"X") |
431 |
> |
MITStyle.SetLabelFont (42 ,"X") |
432 |
> |
|
433 |
> |
MITStyle.SetStripDecimals(kFALSE) |
434 |
> |
|
435 |
> |
MITStyle.SetTitleSize (0.055,"Y") |
436 |
> |
MITStyle.SetTitleOffset(1.300,"Y") |
437 |
> |
MITStyle.SetLabelOffset(0.010,"Y") |
438 |
> |
MITStyle.SetLabelSize (0.050,"Y") |
439 |
> |
MITStyle.SetLabelFont (42 ,"Y") |
440 |
> |
|
441 |
> |
MITStyle.SetTextSize (0.055) |
442 |
> |
MITStyle.SetTextFont (42) |
443 |
> |
|
444 |
> |
MITStyle.SetStatFont (42) |
445 |
> |
MITStyle.SetTitleFont (42) |
446 |
> |
MITStyle.SetTitleFont (42,"X") |
447 |
> |
MITStyle.SetTitleFont (42,"Y") |
448 |
> |
|
449 |
> |
MITStyle.SetPalette (1) |
450 |
> |
|
451 |
> |
MITStyle.SetOptStat (0) |
452 |
> |
#MITStyle.SetOptStat (111111) |
453 |
> |
gROOT.SetStyle("mitStyle") |
454 |
> |
gROOT.ForceStyle() |
455 |
> |
|
456 |
> |
|
457 |
> |
|
458 |
> |
|
459 |
|
if __name__ == '__main__': |
460 |
|
## default style |
461 |
|
gROOT.SetStyle("Plain") |
463 |
|
gStyle.SetPadTickX(1) |
464 |
|
gStyle.SetPadTickY(1) |
465 |
|
|
466 |
+ |
## activate these two style following way: better way |
467 |
+ |
# atlasstyle() |
468 |
+ |
# tdrstyle() |
469 |
+ |
# ildstyle() |
470 |
+ |
# yastyle() |
471 |
+ |
# mitstyle() |
472 |
|
## activate these two style following way |
473 |
< |
## gROOT.SetStyle("ATLAS") |
473 |
> |
## gROOT.SetStyle("atlasStyle") |
474 |
|
## gROOT.SetStyle("tdrStyle") |
475 |
+ |
## gROOT.SetStyle("ildStyle") |
476 |
+ |
## gROOT.SetStyle("yaStyle") |
477 |
+ |
## gROOT.SetStyle("mitStyle") |
478 |
|
## gROOT.ForceStyle() |
479 |
|
|
480 |
|
|