Logo ROOT  
Reference Guide
 
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
17void gr013_polar2()
18{
19 TCanvas * CPol = new TCanvas("CPol","TGraphPolar Example",500,500);
20
21 Double_t theta[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 Double_t
Definition RtypesCore.h:59
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
The Canvas class.
Definition TCanvas.h:23
To draw a polar graph.
Definition TGraphPolar.h:23
constexpr Double_t Pi()
Definition TMath.h:37