ROOT
Version master
master
v6.34
v6.32
v6.30
v6.28
v6.26
v6.24
v6.22
v6.20
v6.18
v6.16
v6.14
v6.12
v6.10
v6.08
v6.06
v6.04
Reference Guide
►
ROOT
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
gr013_polar2.C
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
16
17
void
gr013_polar2
()
18
{
19
TCanvas
*
CPol
=
new
TCanvas
(
"CPol"
,
"TGraphPolar Example"
,500,500);
20
21
Double_t
theta[8];
22
Double_t
radius
[8];
23
Double_t
etheta
[8];
24
Double_t
eradius
[8];
25
26
for
(
int
i=0; i<8; i++) {
27
theta[i] = (i+1)*(
TMath::Pi
()/4.);
28
radius
[i] = (i+1)*0.05;
29
etheta
[i] =
TMath::Pi
()/8.;
30
eradius
[i] = 0.05;
31
}
32
33
TGraphPolar
*
grP1
=
new
TGraphPolar
(8, theta,
radius
,
etheta
,
eradius
);
34
grP1
->SetTitle(
""
);
35
36
grP1
->SetMarkerStyle(20);
37
grP1
->SetMarkerSize(2.);
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
49
}
Double_t
double Double_t
Definition
RtypesCore.h:59
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
TCanvas
The Canvas class.
Definition
TCanvas.h:23
TGraphPolar
To draw a polar graph.
Definition
TGraphPolar.h:23
TMath::Pi
constexpr Double_t Pi()
Definition
TMath.h:37
tutorials
visualisation
graphs
gr013_polar2.C
ROOT master - Reference Guide Generated on Mon Feb 24 2025 14:45:13 (GVA Time) using Doxygen 1.10.0