Loading [MathJax]/extensions/tex2jax.js
ROOT
6.14/05
Reference Guide
ROOT Home
Main Page
Tutorials
Functional Parts
+
Namespaces
Namespace List
+
Namespace Members
+
All
<
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
<
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Variables
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
q
r
s
u
w
x
+
Enumerations
a
e
f
g
m
p
t
v
w
y
+
Enumerator
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
w
+
All Classes
Class List
Class Index
Class Hierarchy
+
Class Members
+
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
+
Enumerations
a
b
c
d
e
f
g
h
i
l
m
o
p
r
s
t
w
y
+
Enumerator
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
+
Properties
f
+
Related Functions
:
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
+
Files
File List
+
File Members
+
All
1
2
3
4
5
6
7
8
9
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
+
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
+
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
+
Enumerations
c
e
f
i
l
m
p
r
u
x
+
Enumerator
a
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
u
v
w
+
Macros
1
2
3
4
5
6
7
8
9
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Release Notes
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
tutorials
pyroot
graph.py
Go to the documentation of this file.
1
## \file
2
## \ingroup tutorial_pyroot
3
## \notebook
4
## A Simple Graph Example
5
##
6
## \macro_image
7
## \macro_output
8
## \macro_code
9
##
10
## \author Wim Lavrijsen
11
12
from
__future__
import
print_function
13
from
ROOT
import
TCanvas, TGraph
14
from
ROOT
import
gROOT
15
from
math
import
sin
16
from
array
import
array
17
18
19
c1 =
TCanvas
(
'c1'
,
'A Simple Graph Example'
, 200, 10, 700, 500 )
20
21
c1.SetFillColor( 42 )
22
c1.SetGrid()
23
24
n = 20
25
x, y = array(
'd'
), array(
'd'
)
26
27
for
i
in
range( n ):
28
x.append( 0.1*i )
29
y.append( 10*
sin
( x[i]+0.2 ) )
30
print(
' i %i %f %f '
% (i,x[i],y[i]))
31
32
gr =
TGraph
( n, x, y )
33
gr.SetLineColor( 2 )
34
gr.SetLineWidth( 4 )
35
gr.SetMarkerColor( 4 )
36
gr.SetMarkerStyle( 21 )
37
gr.SetTitle(
'a simple graph'
)
38
gr.GetXaxis().SetTitle(
'X title'
)
39
gr.GetYaxis().SetTitle(
'Y title'
)
40
gr.Draw(
'ACP'
)
41
42
# TCanvas.Update() draws the frame, after which one can change it
43
c1.Update()
44
c1.GetFrame().
SetFillColor
( 21 )
45
c1.GetFrame().
SetBorderSize
( 12 )
46
c1.Modified()
47
c1.Update()
sin
double sin(double)
SetBorderSize
c SetBorderSize(2)
SetFillColor
h1 SetFillColor(kGreen)
TCanvas
The Canvas class.
Definition:
TCanvas.h:31
TGraph
A Graph is a graphics object made of two arrays X and Y with npoints each.
Definition:
TGraph.h:41