Hello!
As I am now working with angles it would be nice to format the histogram axis labels
0, 0.25pi, 0.5pi, 0.75pi, pi (with nice Greek letter of course)
instead of
0, 0.785, 1.57, 2.355, 3.14
Is there a convenient way to label axes with mathematical and physical constants in Root?
Cheers,
Viesturs
couet
2
That on our TODO list. The only way now is:
{
Double_t pi = TMath::Pi();
TF1* f = new TF1("f","TMath::Cos(x/TMath::Pi())", -pi, pi);
TH1* h = f->GetHistogram();
TAxis* a = h->GetXaxis();
a->SetBit(TAxis::kLabelsHori);
a->SetBinLabel(1,"-#pi");
a->SetBinLabel(50,"0");
a->SetBinLabel(100,"+#pi");
a->SetBit(TAxis::kLabelsHori);
a->SetLabelSize(0.075);
f->Draw();
gPad->Update();
TGaxis* ax = new TGaxis(-pi, gPad->GetUymin(),
pi, gPad->GetUymin(),
-pi, pi, 510, "");
ax->SetLabelSize(0.);
ax->Draw();
}
couet
3