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