Hello,
I’ve been trying without success to plot a polar histogram showing a 2D projection of the surface of a hemisphere that looks pretty. This script is what I have so far:
[code]void polarPlot()
{
TRandom2 angles;
Double_t phi;
Double_t theta;
TH2D * PP = new TH2D(“polarHist”,“Angular Distribution”,360,-(TMath::Pi()), TMath::Pi(),90,0,TMath::PiOver2());
for (int i = 0; i < 10000; i++)
{
phi = angles.Gaus(0,1.6);
theta = angles.Gaus(0.8,0.3);
PP->Fill(phi,theta);
}
PP->SetTitle(“A gaussian distribution over polar coordinates”);
TCanvas * c = new TCanvas(“c”,“c”,800,800);
TH2D * dummy = new TH2D("","",10,-TMath::Pi()/2,TMath::Pi()/2,10,-TMath::Pi()/2,TMath::Pi()/2);
dummy->SetStats(false);
dummy->Draw();
PP->Draw(“polcol2zsame”);
return ;
}
[/code]
This does produce a circular distribution centred in the middle of the canvas, but it does have axes numbered 1,2,3 etc. which I would prefer to be labelled in terms of Pi, and the axes are on the bottom and left, while they might look nicer in the middle of the figure.
I’ve had a look through some of the root documentation and the forums, but haven’t found anything relevant, so I thought I’d ask the question directly.