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