ROOT
6.07/01
Reference Guide
ROOT Home Page
Main Page
Tutorials
User's Classes
Namespaces
All Classes
Files
Release Notes
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
tutorials
pyroot
graph.py
Go to the documentation of this file.
1
#
2
# To see the output of this macro, click begin_html <a href="gif/graph.gif">here</a>. end_html
3
#
4
5
from
ROOT
import
TCanvas, TGraph
6
from
ROOT
import
gROOT
7
from
math
import
sin
8
from
array
import
array
9
10
11
c1 = TCanvas(
'c1'
,
'A Simple Graph Example'
, 200, 10, 700, 500 )
12
13
c1.SetFillColor( 42 )
14
c1.SetGrid()
15
16
n = 20
17
x, y = array(
'd'
), array(
'd'
)
18
19
for
i
in
range( n ):
20
x.append( 0.1*i )
21
y.append( 10*
sin
( x[i]+0.2 ) )
22
print
' i %i %f %f '
% (i,x[i],y[i])
23
24
gr = TGraph( n, x, y )
25
gr.SetLineColor( 2 )
26
gr.SetLineWidth( 4 )
27
gr.SetMarkerColor( 4 )
28
gr.SetMarkerStyle( 21 )
29
gr.SetTitle(
'a simple graph'
)
30
gr.GetXaxis().SetTitle(
'X title'
)
31
gr.GetYaxis().SetTitle(
'Y title'
)
32
gr.Draw(
'ACP'
)
33
34
# TCanvas.Update() draws the frame, after which one can change it
35
c1.Update()
36
c1.GetFrame().
SetFillColor
( 21 )
37
c1.GetFrame().
SetBorderSize
( 12 )
38
c1.Modified()
39
c1.Update()
sin
double sin(double)
SetBorderSize
c SetBorderSize(2)
SetFillColor
h1 SetFillColor(kGreen)