ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
h1draw.py
Go to the documentation of this file.
1 #
2 # To see the output of this macro, click begin_html <a href="gif/h1draw.gif">here</a> end_html
3 #
4 
5 from ROOT import TCanvas, TPad, TFile, TPaveLabel, TPaveText
6 from ROOT import gROOT
7 
8 
9 
10 c1 = TCanvas( 'c1', 'Histogram Drawing Options', 200, 10, 700, 900 )
11 
12 pad1 = TPad( 'pad1', 'The pad with the function', 0.03, 0.62, 0.50, 0.92, 21 )
13 pad2 = TPad( 'pad2', 'The pad with the histogram', 0.51, 0.62, 0.98, 0.92, 21 )
14 pad3 = TPad( 'pad3', 'The pad with the histogram', 0.03, 0.02, 0.97, 0.57, 21 )
15 pad1.Draw()
16 pad2.Draw()
17 pad3.Draw()
18 #
19 # We connect the ROOT file generated in a previous tutorial
20 # see begin_html <a href="hsimple.C.html">An example creating/filling/saving histograms/ntuples on file</a> end_html
21 #
22 example = TFile( 'py-hsimple.root' )
23 example.ls()
24 
25 # Draw a global picture title
26 title = TPaveLabel( 0.1, 0.94, 0.9, 0.98,
27  'Drawing options for one dimensional histograms' )
28 title.SetFillColor( 16 )
29 title.SetTextFont( 52 )
30 title.Draw()
31 #
32 # Draw histogram hpx in first pad with the default option.
33 pad1.cd()
34 pad1.GetFrame().SetFillColor( 18 )
35 hpx = gROOT.FindObject( 'hpx' )
36 hpx.SetFillColor( 45 )
37 hpx.DrawCopy()
38 label1 = TPaveLabel( -3.5, 700, -1, 800, 'Default option' )
39 label1.SetFillColor( 42 )
40 label1.Draw()
41 #
42 # Draw hpx as a lego. Clicking on the lego area will show
43 # a "transparent cube" to guide you rotating the lego in real time.
44 pad2.cd()
45 hpx.DrawCopy( 'lego1' )
46 label2 = TPaveLabel( -0.72, 0.74, -0.22, 0.88, 'option Lego1' )
47 label2.SetFillColor( 42 )
48 label2.Draw()
49 label2a = TPaveLabel( -0.93, -1.08, 0.25, -0.92, 'Click on lego to rotate' )
50 label2a.SetFillColor( 42 )
51 label2a.Draw()
52 #
53 # Draw hpx with its errors and a marker.
54 pad3.cd()
55 pad3.SetGridx()
56 pad3.SetGridy()
57 pad3.GetFrame().SetFillColor( 18 )
58 hpx.SetMarkerStyle( 21 )
59 hpx.Draw( 'e1p' )
60 label3 = TPaveLabel( 2, 600, 3.5, 650, 'option e1p' )
61 label3.SetFillColor( 42 )
62 label3.Draw()
63 #
64 # The following illustrates how to add comments using a PaveText.
65 # Attributes of text/lines/boxes added to a PaveText can be modified.
66 # The AddText function returns a pointer to the added object.
67 pave = TPaveText( -3.78, 500, -1.2, 750 )
68 pave.SetFillColor( 42 )
69 t1 = pave.AddText( 'You can move' )
70 t1.SetTextColor( 4 )
71 t1.SetTextSize( 0.05 )
72 pave.AddText( 'Title and Stats pads' )
73 pave.AddText( 'X and Y axis' )
74 pave.AddText( 'You can modify bin contents' )
75 pave.Draw()
76 c1.Update()
h1 SetFillColor(kGreen)