ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/wangdy/sys/rootstyle.py
(Generate patch)

Comparing UserCode/wangdy/sys/rootstyle.py (file contents):
Revision 1.4 by wangdy, Fri Jun 26 10:13:31 2009 UTC vs.
Revision 1.7 by wangdy, Thu Jul 15 16:22:47 2010 UTC

# Line 1 | Line 1
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   ##
# Line 17 | Line 26
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  
# Line 30 | Line 42 | def atlasstyle():
42  
43      global atlasStyle
44      ##.. style from RooLogon.C in workdir
33    ## atlasStyle=TStyle("ATLAS","Atlas style")
45  
46      ## use plain black on white colors
47      icol=0
# Line 48 | Line 59 | def atlasstyle():
59  
60      ## with title:0.07 ;no title:0.05    
61      atlasStyle.SetPadTopMargin(0.07)
62 <    atlasStyle.SetPadRightMargin(0.05)
62 >    atlasStyle.SetPadRightMargin(0.10)
63  
64      ## with title:0.14 ;no title:0.16        
65      atlasStyle.SetPadBottomMargin(0.14)
# Line 95 | Line 106 | def atlasstyle():
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  
# Line 179 | Line 191 | def tdrstyle():
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
# Line 220 | Line 232 | def tdrstyle():
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)
# Line 265 | Line 281 | def ildstyle():
281      ildStyle.SetLegendBorderSize(0)
282  
283      #use the primary color palette
284 <    ildStyle.SetPalette(1,0)
284 >    ildStyle.SetPalette(1)
285  
286      #set the default line color for a histogram to be black
287      ildStyle.SetHistLineColor(kBlack)
# Line 343 | Line 359 | def yastyle():
359      yaStyle.SetMarkerSize(0.5)
360      yaStyle.SetMarkerStyle(8)
361      yaStyle.SetGridStyle(3)
362 <    yaStyle.SetPaperSize(TStyle::kA4)
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
# Line 361 | Line 377 | def yastyle():
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
494      gROOT.SetStyle("Plain")
# Line 373 | Line 501 | if __name__ == '__main__':
501   #     tdrstyle()
502   #     ildstyle()
503   #     yastyle()
504 <
504 > #     mitstyle()
505   ## activate these two style following way
506   ## gROOT.SetStyle("atlasStyle")
507   ## gROOT.SetStyle("tdrStyle")
508   ## gROOT.SetStyle("ildStyle")
509 < ## gROOT.SetStyle("yaStyle")    
509 > ## gROOT.SetStyle("yaStyle")
510 > ## gROOT.SetStyle("mitStyle")    
511   ## gROOT.ForceStyle()
512  
513  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines