Logo ROOT   6.12/07
Reference Guide
first.py
Go to the documentation of this file.
1 ## \file
2 ## \ingroup tutorial_pyroot
3 ## \notebook
4 ## My first PyROOT interactive session
5 ##
6 ## \macro_image
7 ## \macro_code
8 ##
9 ## \author Wim Lavrijsen
10 
11 from ROOT import TCanvas, TF1, TPaveLabel, TPad, TText
12 from ROOT import gROOT
13 
14 
15 nut = TCanvas( 'nut', 'FirstSession', 100, 10, 700, 900 )
16 nut.Range( 0, 0, 20, 24 )
17 nut.SetFillColor( 10 )
18 nut.SetBorderSize( 2 )
19 
20 pl = TPaveLabel( 3, 22, 17, 23.7, 'My first PyROOT interactive session', 'br' )
21 pl.SetFillColor( 18 )
22 pl.Draw()
23 
24 t = TText( 0, 0, 'a' )
25 t.SetTextFont( 62 )
26 t.SetTextSize( 0.025 )
27 t.SetTextAlign( 12 )
28 t.DrawText( 2, 20.3, 'PyROOT provides ROOT bindings for Python, a powerful interpreter.' )
29 t.DrawText( 2, 19.3, 'Blocks of lines can be entered typographically.' )
30 t.DrawText( 2, 18.3, 'Previous typed lines can be recalled.' )
31 
32 t.SetTextFont( 72 )
33 t.SetTextSize( 0.026 )
34 t.DrawText( 3, 17, r'>>> x, y = 5, 7' )
35 t.DrawText( 3, 16, r'>>> import math; x*math.sqrt(y)' )
36 t.DrawText( 3, 14, r'>>> for i in range(2,7): print "sqrt(%d) = %f" % (i,math.sqrt(i))' )
37 t.DrawText( 3, 10, r'>>> import ROOT; f1 = ROOT.TF1( "f1", "sin(x)/x", 0, 10 )' )
38 t.DrawText( 3, 9, r'>>> f1.Draw()' )
39 t.SetTextFont( 81 )
40 t.SetTextSize( 0.018 )
41 t.DrawText( 4, 15, '13.228756555322953' )
42 t.DrawText( 4, 13.3, 'sqrt(2) = 1.414214' )
43 t.DrawText( 4, 12.7, 'sqrt(3) = 1.732051' )
44 t.DrawText( 4, 12.1, 'sqrt(4) = 2.000000' )
45 t.DrawText( 4, 11.5, 'sqrt(5) = 2.236068' )
46 t.DrawText( 4, 10.9, 'sqrt(6) = 2.449490' )
47 
48 pad = TPad( 'pad', 'pad', .2, .05, .8, .35 )
49 pad.SetFillColor( 42 )
50 pad.SetFrameFillColor( 33 )
51 pad.SetBorderSize( 10 )
52 pad.Draw()
53 pad.cd()
54 pad.SetGrid()
55 
56 f1 = TF1( 'f1', 'sin(x)/x', 0, 10 )
57 f1.Draw()
58 nut.cd()
59 nut.Update()
Base class for several text objects.
Definition: TText.h:23
A Pave (see TPave) with a text centered in the Pave.
Definition: TPaveLabel.h:20
The most important graphics class in the ROOT system.
Definition: TPad.h:29
The Canvas class.
Definition: TCanvas.h:31
1-Dim function class
Definition: TF1.h:211