Logo ROOT   6.07/09
Reference Guide
Namespaces
first.py File Reference

Namespaces

 first
 

Detailed Description

View in nbviewer Open in SWAN My first PyROOT interactive session

pict1_first.py.png
1 
2 from ROOT import TCanvas, TF1, TPaveLabel, TPad, TText
3 from ROOT import gROOT
4 
5 
6 nut = TCanvas( 'nut', 'FirstSession', 100, 10, 700, 900 )
7 nut.Range( 0, 0, 20, 24 )
8 nut.SetFillColor( 10 )
9 nut.SetBorderSize( 2 )
10 
11 pl = TPaveLabel( 3, 22, 17, 23.7, 'My first PyROOT interactive session', 'br' )
12 pl.SetFillColor( 18 )
13 pl.Draw()
14 
15 t = TText( 0, 0, 'a' )
16 t.SetTextFont( 62 )
17 t.SetTextSize( 0.025 )
18 t.SetTextAlign( 12 )
19 t.DrawText( 2, 20.3, 'PyROOT provides ROOT bindings for Python, a powerful interpreter.' )
20 t.DrawText( 2, 19.3, 'Blocks of lines can be entered typographically.' )
21 t.DrawText( 2, 18.3, 'Previous typed lines can be recalled.' )
22 
23 t.SetTextFont( 72 )
24 t.SetTextSize( 0.026 )
25 t.DrawText( 3, 17, r'>>> x, y = 5, 7' )
26 t.DrawText( 3, 16, r'>>> import math; x*math.sqrt(y)' )
27 t.DrawText( 3, 14, r'>>> for i in range(2,7): print "sqrt(%d) = %f" % (i,math.sqrt(i))' )
28 t.DrawText( 3, 10, r'>>> import ROOT; f1 = ROOT.TF1( "f1", "sin(x)/x", 0, 10 )' )
29 t.DrawText( 3, 9, r'>>> f1.Draw()' )
30 t.SetTextFont( 81 )
31 t.SetTextSize( 0.018 )
32 t.DrawText( 4, 15, '13.228756555322953' )
33 t.DrawText( 4, 13.3, 'sqrt(2) = 1.414214' )
34 t.DrawText( 4, 12.7, 'sqrt(3) = 1.732051' )
35 t.DrawText( 4, 12.1, 'sqrt(4) = 2.000000' )
36 t.DrawText( 4, 11.5, 'sqrt(5) = 2.236068' )
37 t.DrawText( 4, 10.9, 'sqrt(6) = 2.449490' )
38 
39 pad = TPad( 'pad', 'pad', .2, .05, .8, .35 )
40 pad.SetFillColor( 42 )
41 pad.SetFrameFillColor( 33 )
42 pad.SetBorderSize( 10 )
43 pad.Draw()
44 pad.cd()
45 pad.SetGrid()
46 
47 f1 = TF1( 'f1', 'sin(x)/x', 0, 10 )
48 f1.Draw()
49 nut.cd()
50 nut.Update()
Author
Wim Lavrijsen

Definition in file first.py.