Hi!
I’m trying to produce a TH2 polar plot:
void test () {
gStyle->SetOptStat(0);
Double_t theta[] = {30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360};
double r = 0.06;
TCanvas* c = new TCanvas("c", "c", 800, 800);
TH2D* d = new TH2D("d", "", 2, -1, 1, 2, -1, 1);
TH2D* h = new TH2D("p", "", 12, 0, 360, 12, 0, 1);
d->GetXaxis()->SetLabelSize(0);
d->GetYaxis()->SetLabelSize(0);
for (double t : theta) {
h->Fill(t, r);
r += 0.06;
}
d->Draw("COL");
h->Draw("col pol same");
}
The output:
I digged a bit in the forum here and I couldn’t find a way to avoid a dummy TH2 in order to draw the polar plot correctly. Is it mandatory?
Above all, why do I get a doily instead of the funny iridescent circle I want?
PS:
Sorry for bothering over and over, almost every single day.
couet
March 14, 2019, 1:35pm
2
I must admit I do not really understand the result you get … May be using the POL option on Lego would be better ?
{
gStyle->SetOptStat(0);
Double_t theta[] = {30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360};
double r = 0.06;
TCanvas* c = new TCanvas("c", "c", 800, 800);
c->SetTheta(90);
c->SetPhi(0.);
TH2D* h = new TH2D("p", "", 12, 0, 360, 12, 0, 1);
for (double t : theta) {
h->Fill(t, r);
r += 0.06;
}
h->Draw("lego2 pol");
}
1 Like
That’s much better.
Is it possible to get circular sectors instead of triangles?
couet
March 14, 2019, 1:41pm
4
This is because you have a few bins only… with more bins it will be more circular.
Uhm…
Optical effects then.
One last thing: how to rotate the circle by 90 deg clockwise?
system
Closed
March 28, 2019, 2:05pm
8
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.