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 File Reference

Detailed Description

View in nbviewer Open in SWAN
Create and draw a polar graph with errors and polar axis in radians (PI fractions).

See the TGraphPolar documentation

Since TGraphPolar is a TGraphErrors, it is painted with TGraphPainter options.

With GetPolargram we retrieve the polar axis to format it; see the TGraphPolargram documentation

{
TCanvas * CPol = new TCanvas("CPol","TGraphPolar Example",500,500);
Double_t theta[8];
for (int i=0; i<8; i++) {
theta[i] = (i+1)*(TMath::Pi()/4.);
radius[i] = (i+1)*0.05;
etheta[i] = TMath::Pi()/8.;
eradius[i] = 0.05;
}
grP1->SetTitle("");
grP1->SetMarkerStyle(20);
grP1->SetMarkerSize(2.);
grP1->SetMarkerColor(4);
grP1->SetLineColor(2);
grP1->SetLineWidth(3);
// Draw with polymarker and errors
grP1->Draw("PE");
// To format the polar axis, we retrieve the TGraphPolargram.
// First update the canvas, otherwise GetPolargram returns 0
CPol->Update();
if (grP1->GetPolargram())
grP1->GetPolargram()->SetToRadian(); // tell ROOT that the theta values are in radians
}
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
Author
Olivier Couet

Definition in file gr013_polar2.C.