1 |
|
## |
2 |
|
## $Log$ |
3 |
+ |
## Revision 1.7 2010/07/15 16:22:47 wangdy |
4 |
+ |
## change the pad right margin to allow for COLZ;use palatte from R.Reece |
5 |
+ |
## |
6 |
+ |
## Revision 1.6 2010/05/18 17:20:12 wangdy |
7 |
+ |
## small updates |
8 |
+ |
## |
9 |
+ |
## Revision 1.5 2009/06/30 08:59:19 wangdy |
10 |
+ |
## add mitstyle and some style functions |
11 |
+ |
## |
12 |
+ |
## Revision 1.4 2009/06/26 10:13:31 wangdy |
13 |
+ |
## first import ildstyle; add yastyle and ildstyle directly into root logon |
14 |
+ |
## |
15 |
+ |
## Revision 1.3 2008/01/18 15:51:18 wangdy |
16 |
+ |
## adjust top margin of the pad w/(o) title |
17 |
+ |
## |
18 |
|
## Revision 1.2 2008/01/18 11:33:19 wangdy |
19 |
|
## add setting for title color |
20 |
|
## |
26 |
|
""" Dayong's rootlogon file, python version """ |
27 |
|
|
28 |
|
from ROOT import * |
29 |
+ |
from array import array |
30 |
+ |
|
31 |
+ |
|
32 |
+ |
atlasStyle=TStyle("atlasStyle","Atlas style") |
33 |
+ |
tdrStyle = TStyle("tdrStyle","Style for P-TDR") |
34 |
+ |
ildStyle = TStyle("ildStyle","ILD Style") |
35 |
+ |
yaStyle = TStyle("yaStyle","Yet Another Style, for talks") |
36 |
+ |
MITStyle = TStyle("mitStyle","The Perfect Style for Plots ;-)"); |
37 |
+ |
|
38 |
|
|
39 |
|
def atlasstyle(): |
40 |
|
|
42 |
|
|
43 |
|
global atlasStyle |
44 |
|
##.. style from RooLogon.C in workdir |
21 |
– |
## atlasStyle=TStyle("ATLAS","Atlas style") |
45 |
|
|
46 |
|
## use plain black on white colors |
47 |
|
icol=0 |
48 |
|
atlasStyle.SetFrameBorderMode(icol) |
49 |
+ |
atlasStyle.SetFrameFillColor(icol) |
50 |
|
atlasStyle.SetCanvasBorderMode(icol) |
51 |
|
atlasStyle.SetPadBorderMode(icol) |
52 |
|
atlasStyle.SetPadColor(icol) |
56 |
|
|
57 |
|
## set the paper & margin sizes |
58 |
|
atlasStyle.SetPaperSize(20,26) |
59 |
< |
atlasStyle.SetPadTopMargin(0.05) |
60 |
< |
atlasStyle.SetPadRightMargin(0.05) |
61 |
< |
atlasStyle.SetPadBottomMargin(0.16) |
59 |
> |
|
60 |
> |
## with title:0.07 ;no title:0.05 |
61 |
> |
atlasStyle.SetPadTopMargin(0.07) |
62 |
> |
atlasStyle.SetPadRightMargin(0.10) |
63 |
> |
|
64 |
> |
## with title:0.14 ;no title:0.16 |
65 |
> |
atlasStyle.SetPadBottomMargin(0.14) |
66 |
|
atlasStyle.SetPadLeftMargin(0.12) |
67 |
|
|
68 |
|
## use large fonts |
106 |
|
##atlasStyle.SetOptFit(1111) |
107 |
|
atlasStyle.SetOptFit(0) |
108 |
|
|
109 |
+ |
atlasStyle.SetPalette(1); |
110 |
|
## put tick marks on top and RHS of plots |
111 |
|
atlasStyle.SetPadTickX(1) |
112 |
|
atlasStyle.SetPadTickY(1) |
113 |
< |
gROOT.SetStyle("ATLAS") |
113 |
> |
gROOT.SetStyle("atlasStyle") |
114 |
|
gROOT.ForceStyle() |
115 |
|
|
116 |
|
|
120 |
|
Here is CMS ptdr style |
121 |
|
""" |
122 |
|
global tdrStyle |
123 |
< |
# tdrStyle = TStyle("tdrStyle","Style for P-TDR") |
123 |
> |
## tdrStyle = TStyle("tdrStyle","Style for P-TDR") |
124 |
|
|
125 |
|
## For the canvas: |
126 |
|
tdrStyle.SetCanvasBorderMode(0) |
191 |
|
|
192 |
|
## Margins: |
193 |
|
tdrStyle.SetPadTopMargin(0.05) |
194 |
< |
tdrStyle.SetPadBottomMargin(0.13) |
195 |
< |
tdrStyle.SetPadLeftMargin(0.16) |
196 |
< |
tdrStyle.SetPadRightMargin(0.02) |
194 |
> |
tdrStyle.SetPadBottomMargin(0.15) |
195 |
> |
tdrStyle.SetPadLeftMargin(0.15) |
196 |
> |
tdrStyle.SetPadRightMargin(0.12) |
197 |
|
|
198 |
|
## For the Global title: |
199 |
|
tdrStyle.SetOptTitle(0) |
200 |
|
tdrStyle.SetTitleFont(42) |
201 |
|
tdrStyle.SetTitleColor(1) |
202 |
|
tdrStyle.SetTitleTextColor(1) |
203 |
< |
tdrStyle.SetTitleFillColor(0) |
203 |
> |
tdrStyle.SetTitleFillColor(10) |
204 |
|
tdrStyle.SetTitleFontSize(0.05) |
205 |
|
## tdrStyle.SetTitleH(0) ## Set the height of the title box |
206 |
|
## tdrStyle.SetTitleW(0) ## Set the width of the title box |
232 |
|
tdrStyle.SetNdivisions(510, "XYZ") |
233 |
|
tdrStyle.SetPadTickX(1) ## To get tick marks on the opposite side of the frame |
234 |
|
tdrStyle.SetPadTickY(1) |
235 |
+ |
|
236 |
+ |
## for the palette: |
237 |
+ |
tdrStyle.SetPalette(1); |
238 |
+ |
## tdrStyle.SetNumberContours(8); |
239 |
|
|
240 |
|
## Change for log plots: |
241 |
|
tdrStyle.SetOptLogx(0) |
258 |
|
gROOT.SetStyle("tdrStyle") |
259 |
|
gROOT.ForceStyle() |
260 |
|
|
261 |
< |
atlasStyle=TStyle("ATLAS","Atlas style") |
262 |
< |
tdrStyle = TStyle("tdrStyle","Style for P-TDR") |
261 |
> |
def ildstyle(): |
262 |
> |
|
263 |
> |
""" |
264 |
> |
Here is ILD style |
265 |
> |
""" |
266 |
> |
global ildStyle |
267 |
> |
|
268 |
> |
|
269 |
> |
#set the background color to white |
270 |
> |
ildStyle.SetFillColor(10) |
271 |
> |
ildStyle.SetFrameFillColor(10) |
272 |
> |
ildStyle.SetCanvasColor(10) |
273 |
> |
ildStyle.SetPadColor(10) |
274 |
> |
ildStyle.SetTitleFillColor(0) |
275 |
> |
ildStyle.SetStatColor(10) |
276 |
> |
|
277 |
> |
#dont put a colored frame around the plots |
278 |
> |
ildStyle.SetFrameBorderMode(0) |
279 |
> |
ildStyle.SetCanvasBorderMode(0) |
280 |
> |
ildStyle.SetPadBorderMode(0) |
281 |
> |
ildStyle.SetLegendBorderSize(0) |
282 |
> |
|
283 |
> |
#use the primary color palette |
284 |
> |
ildStyle.SetPalette(1) |
285 |
> |
|
286 |
> |
#set the default line color for a histogram to be black |
287 |
> |
ildStyle.SetHistLineColor(kBlack) |
288 |
> |
|
289 |
> |
#set the default line color for a fit function to be red |
290 |
> |
ildStyle.SetFuncColor(kRed) |
291 |
> |
|
292 |
> |
#make the axis labels black |
293 |
> |
ildStyle.SetLabelColor(kBlack,"xyz") |
294 |
> |
|
295 |
> |
#set the default title color to be black |
296 |
> |
ildStyle.SetTitleColor(kBlack) |
297 |
> |
|
298 |
> |
#set the margins |
299 |
> |
ildStyle.SetPadBottomMargin(0.18) |
300 |
> |
ildStyle.SetPadTopMargin(0.08) |
301 |
> |
ildStyle.SetPadRightMargin(0.08) |
302 |
> |
ildStyle.SetPadLeftMargin(0.17) |
303 |
> |
|
304 |
> |
#set axis label and title text sizes |
305 |
> |
ildStyle.SetLabelFont(42,"xyz") |
306 |
> |
ildStyle.SetLabelSize(0.06,"xyz") |
307 |
> |
ildStyle.SetLabelOffset(0.015,"xyz") |
308 |
> |
ildStyle.SetTitleFont(42,"xyz") |
309 |
> |
ildStyle.SetTitleSize(0.07,"xyz") |
310 |
> |
ildStyle.SetTitleOffset(1.1,"yz") |
311 |
> |
ildStyle.SetTitleOffset(1.0,"x") |
312 |
> |
ildStyle.SetStatFont(42) |
313 |
> |
ildStyle.SetStatFontSize(0.07) |
314 |
> |
ildStyle.SetTitleBorderSize(0) |
315 |
> |
ildStyle.SetStatBorderSize(0) |
316 |
> |
ildStyle.SetTextFont(42) |
317 |
> |
|
318 |
> |
#set line widths |
319 |
> |
ildStyle.SetFrameLineWidth(2) |
320 |
> |
ildStyle.SetFuncWidth(2) |
321 |
> |
ildStyle.SetHistLineWidth(2) |
322 |
> |
|
323 |
> |
#set the number of divisions to show |
324 |
> |
ildStyle.SetNdivisions(506, "xy") |
325 |
> |
|
326 |
> |
#turn off xy grids |
327 |
> |
ildStyle.SetPadGridX(0) |
328 |
> |
ildStyle.SetPadGridY(0) |
329 |
> |
|
330 |
> |
#set the tick mark style |
331 |
> |
ildStyle.SetPadTickX(1) |
332 |
> |
ildStyle.SetPadTickY(1) |
333 |
> |
|
334 |
> |
#turn off stats |
335 |
> |
ildStyle.SetOptStat(0) |
336 |
> |
ildStyle.SetOptFit(0) |
337 |
> |
|
338 |
> |
#marker settings |
339 |
> |
ildStyle.SetMarkerStyle(20) |
340 |
> |
ildStyle.SetMarkerSize(0.7) |
341 |
> |
ildStyle.SetLineWidth(2) |
342 |
> |
|
343 |
> |
gROOT.SetStyle("ildStyle") |
344 |
> |
gROOT.ForceStyle() |
345 |
> |
|
346 |
> |
def yastyle(): |
347 |
> |
|
348 |
> |
""" |
349 |
> |
Here is Yet Another style |
350 |
> |
""" |
351 |
> |
global yaStyle |
352 |
> |
|
353 |
> |
yaStyle.SetFillColor(0) |
354 |
> |
yaStyle.SetOptDate() |
355 |
> |
yaStyle.SetOptStat(111110) |
356 |
> |
yaStyle.SetOptFit(1111) |
357 |
> |
yaStyle.SetPadTickX(1) |
358 |
> |
yaStyle.SetPadTickY(1) |
359 |
> |
yaStyle.SetMarkerSize(0.5) |
360 |
> |
yaStyle.SetMarkerStyle(8) |
361 |
> |
yaStyle.SetGridStyle(3) |
362 |
> |
yaStyle.SetPaperSize(kA4) |
363 |
> |
yaStyle.SetStatW(0.35) # width of statistics box; default is 0.19 |
364 |
> |
yaStyle.SetStatH(0.20) # height of statistics box; default is 0.1 |
365 |
> |
yaStyle.SetStatFormat("6.4g") # leave default format for now |
366 |
> |
yaStyle.SetTitleSize(0.055, "") # size for pad title; default is 0.02 |
367 |
> |
# Really big; useful for talks. |
368 |
> |
yaStyle.SetTitleSize(0.1, "") # size for pad title; default is 0.02 |
369 |
> |
yaStyle.SetLabelSize(0.05, "XYZ") # size for axis labels; default is 0.04 |
370 |
> |
yaStyle.SetStatFontSize(0.06) # size for stat. box |
371 |
> |
yaStyle.SetTitleFont(32, "XYZ") # times-bold-italic font (p. 153) for axes |
372 |
> |
yaStyle.SetTitleFont(32, "") # same for pad title |
373 |
> |
yaStyle.SetLabelFont(32, "XYZ") # same for axis labels |
374 |
> |
yaStyle.SetStatFont(32) # same for stat. box |
375 |
> |
yaStyle.SetLabelOffset(0.006, "Y") # default is 0.005 |
376 |
> |
|
377 |
> |
gROOT.SetStyle("yaStyle") |
378 |
> |
gROOT.ForceStyle() |
379 |
> |
|
380 |
> |
def mitstyle(): |
381 |
> |
global MITStyle |
382 |
> |
# Canvas |
383 |
> |
MITStyle.SetCanvasColor (0) |
384 |
> |
MITStyle.SetCanvasBorderSize(10) |
385 |
> |
MITStyle.SetCanvasBorderMode(0) |
386 |
> |
MITStyle.SetCanvasDefH (700) |
387 |
> |
MITStyle.SetCanvasDefW (700) |
388 |
> |
MITStyle.SetCanvasDefX (100) |
389 |
> |
MITStyle.SetCanvasDefY (100) |
390 |
> |
|
391 |
> |
# Pads |
392 |
> |
MITStyle.SetPadColor (0) |
393 |
> |
MITStyle.SetPadBorderSize (10) |
394 |
> |
MITStyle.SetPadBorderMode (0) |
395 |
> |
MITStyle.SetPadBottomMargin(0.13) |
396 |
> |
MITStyle.SetPadTopMargin (0.08) |
397 |
> |
MITStyle.SetPadLeftMargin (0.15) |
398 |
> |
MITStyle.SetPadRightMargin (0.05) |
399 |
> |
MITStyle.SetPadGridX (0) |
400 |
> |
MITStyle.SetPadGridY (0) |
401 |
> |
MITStyle.SetPadTickX (0) |
402 |
> |
MITStyle.SetPadTickY (0) |
403 |
> |
|
404 |
> |
# Frames |
405 |
> |
MITStyle.SetFrameFillStyle ( 0) |
406 |
> |
MITStyle.SetFrameFillColor ( 0) |
407 |
> |
MITStyle.SetFrameLineColor ( 1) |
408 |
> |
MITStyle.SetFrameLineStyle ( 0) |
409 |
> |
MITStyle.SetFrameLineWidth ( 1) |
410 |
> |
MITStyle.SetFrameBorderSize(10) |
411 |
> |
MITStyle.SetFrameBorderMode( 0) |
412 |
> |
|
413 |
> |
# Histograms |
414 |
> |
MITStyle.SetHistFillColor(2) |
415 |
> |
MITStyle.SetHistFillStyle(0) |
416 |
> |
MITStyle.SetHistLineColor(1) |
417 |
> |
MITStyle.SetHistLineStyle(0) |
418 |
> |
MITStyle.SetHistLineWidth(2) |
419 |
> |
MITStyle.SetNdivisions(505) |
420 |
> |
|
421 |
> |
# Functions |
422 |
> |
MITStyle.SetFuncColor(1) |
423 |
> |
MITStyle.SetFuncStyle(0) |
424 |
> |
MITStyle.SetFuncWidth(2) |
425 |
> |
|
426 |
> |
# Various |
427 |
> |
MITStyle.SetMarkerStyle(20) |
428 |
> |
MITStyle.SetMarkerColor(kBlack) |
429 |
> |
MITStyle.SetMarkerSize (1.2) |
430 |
> |
|
431 |
> |
MITStyle.SetTitleSize (0.055,"X") |
432 |
> |
MITStyle.SetTitleOffset(0.900,"X") |
433 |
> |
MITStyle.SetLabelOffset(0.005,"X") |
434 |
> |
MITStyle.SetLabelSize (0.050,"X") |
435 |
> |
MITStyle.SetLabelFont (42 ,"X") |
436 |
> |
|
437 |
> |
MITStyle.SetStripDecimals(kFALSE) |
438 |
> |
|
439 |
> |
MITStyle.SetTitleSize (0.055,"Y") |
440 |
> |
MITStyle.SetTitleOffset(1.300,"Y") |
441 |
> |
MITStyle.SetLabelOffset(0.010,"Y") |
442 |
> |
MITStyle.SetLabelSize (0.050,"Y") |
443 |
> |
MITStyle.SetLabelFont (42 ,"Y") |
444 |
> |
|
445 |
> |
MITStyle.SetTextSize (0.055) |
446 |
> |
MITStyle.SetTextFont (42) |
447 |
> |
|
448 |
> |
MITStyle.SetStatFont (42) |
449 |
> |
MITStyle.SetTitleFont (42) |
450 |
> |
MITStyle.SetTitleFont (42,"X") |
451 |
> |
MITStyle.SetTitleFont (42,"Y") |
452 |
> |
|
453 |
> |
MITStyle.SetPalette (1) |
454 |
> |
|
455 |
> |
MITStyle.SetOptStat (0) |
456 |
> |
#MITStyle.SetOptStat (111111) |
457 |
> |
gROOT.SetStyle("mitStyle") |
458 |
> |
gROOT.ForceStyle() |
459 |
> |
|
460 |
> |
def set_palette(name='default', ncontours=200): |
461 |
> |
"""Set a color palette from a given RGB list |
462 |
> |
stops, red, green and blue should all be lists of the same length |
463 |
> |
see set_decent_colors for an example""" |
464 |
> |
|
465 |
> |
if name == 'gray' or name == 'grayscale': |
466 |
> |
stops = [0.00, 0.34, 0.61, 0.84, 1.00] |
467 |
> |
red = [1.00, 0.84, 0.61, 0.34, 0.00] |
468 |
> |
green = [1.00, 0.84, 0.61, 0.34, 0.00] |
469 |
> |
blue = [1.00, 0.84, 0.61, 0.34, 0.00] |
470 |
> |
# elif name == "whatever": |
471 |
> |
# (define more palettes) |
472 |
> |
else: |
473 |
> |
# default palette, looks cool |
474 |
> |
stops = [0.00, 0.34, 0.61, 0.84, 1.00] |
475 |
> |
red = [0.00, 0.00, 0.87, 1.00, 0.51] |
476 |
> |
green = [0.00, 0.81, 1.00, 0.20, 0.00] |
477 |
> |
blue = [0.51, 1.00, 0.12, 0.00, 0.00] |
478 |
> |
|
479 |
> |
s = array('d', stops) |
480 |
> |
r = array('d', red) |
481 |
> |
g = array('d', green) |
482 |
> |
b = array('d', blue) |
483 |
> |
|
484 |
> |
npoints = len(s) |
485 |
> |
TColor.CreateGradientColorTable(npoints, s, r, g, b, ncontours) |
486 |
> |
gStyle.SetNumberContours(ncontours) |
487 |
> |
|
488 |
> |
|
489 |
> |
tdrstyle() |
490 |
> |
set_palette() |
491 |
> |
|
492 |
|
if __name__ == '__main__': |
493 |
< |
## default style |
493 |
> |
## default style |
494 |
|
gROOT.SetStyle("Plain") |
495 |
|
gStyle.SetOptStat(1111111) |
496 |
|
gStyle.SetPadTickX(1) |
497 |
|
gStyle.SetPadTickY(1) |
498 |
|
|
499 |
+ |
## activate these two style following way: better way |
500 |
+ |
# atlasstyle() |
501 |
+ |
# tdrstyle() |
502 |
+ |
# ildstyle() |
503 |
+ |
# yastyle() |
504 |
+ |
# mitstyle() |
505 |
|
## activate these two style following way |
506 |
< |
## gROOT.SetStyle("ATLAS") |
506 |
> |
## gROOT.SetStyle("atlasStyle") |
507 |
|
## gROOT.SetStyle("tdrStyle") |
508 |
+ |
## gROOT.SetStyle("ildStyle") |
509 |
+ |
## gROOT.SetStyle("yaStyle") |
510 |
+ |
## gROOT.SetStyle("mitStyle") |
511 |
|
## gROOT.ForceStyle() |
512 |
|
|
513 |
|
|