ROOT
master
Reference Guide
Loading...
Searching...
No Matches
gr013_polar2.py
Go to the documentation of this file.
1
## \file
2
## \ingroup tutorial_graphs
3
## \notebook
4
## \preview Create and draw a polar graph with errors and polar axis in radians (PI fractions).
5
## See the [TGraphPolar documentation](https:#root.cern/doc/master/classTGraphPolar.html)
6
##
7
## Since TGraphPolar is a TGraphErrors, it is painted with
8
## [TGraphPainter](https:#root.cern/doc/master/classTGraphPainter.html) options.
9
##
10
## With GetPolargram we retrieve the polar axis to format it see the
11
## [TGraphPolargram documentation](https:#root.cern/doc/master/classTGraphPolargram.html)
12
##
13
## \macro_image
14
## \macro_code
15
## \author Olivier Couet, Jamie Gooding
16
17
import
numpy
as
np
18
import
ROOT
19
20
CPol =
ROOT.TCanvas
(
"CPol"
,
"TGraphPolar Example"
, 500, 500)
21
22
theta =
np.array
([])
23
radius =
np.array
([])
24
etheta =
np.array
([])
25
eradius =
np.array
([])
26
27
for
i
in
range
(8):
28
theta =
np.append
(theta, (i + 1) * (
np.pi
/ 4.0))
29
radius =
np.append
(radius, (i + 1) * 0.05)
30
etheta =
np.append
(etheta,
np.pi
/ 8.0)
31
eradius =
np.append
(eradius, 0.05)
32
33
grP1 =
ROOT.TGraphPolar
(8, theta, radius, etheta, eradius)
34
grP1.SetTitle
(
""
)
35
36
grP1.SetMarkerStyle
(20)
37
grP1.SetMarkerSize
(2.0)
38
grP1.SetMarkerColor
(4)
39
grP1.SetLineColor
(2)
40
grP1.SetLineWidth
(3)
41
# Draw with polymarker and errors
42
grP1.Draw
(
"PE"
)
43
44
# To format the polar axis, we retrieve the TGraphPolargram.
45
# First update the canvas, otherwise GetPolargram returns 0
46
CPol.Update
()
47
if
grP1.GetPolargram
():
48
grP1.GetPolargram
().SetToRadian()
# tell ROOT that the theta values are in radians
TRangeDynCast
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Definition
TCollection.h:358
ROOT::Detail::TRangeCast
Definition
TCollection.h:311
tutorials
visualisation
graphs
gr013_polar2.py
ROOT master - Reference Guide Generated on Thu May 22 2025 05:48:34 (GVA Time) using Doxygen 1.10.0