1D histogram custom labels


I am plotting an angle from 0 to pi and would like the tick marks at fractions of pi ( i.e. pi/4, pi/2, etc ) and the label of these tick marks to actually be pi/4 etc and not the decimal equivalent.

I cannot find any documentation that shows how to tell an axis to do this. Surely there is a simple way.


The pi axis is not currently implemented (it will be). As a workaround see the example below


{ Double_t pi = TMath::Pi(); TH1F h("h","test",100,-pi,pi); h.FillRandom("gaus",5000); h.GetXaxis()->SetLabelOffset(99); h.GetXaxis()->SetNdivisions(-4); h.Draw(); TLatex l; l.SetTextSize(0.04); l.SetTextAlign(23); double yl = -2; l.DrawLatex(-pi,yl,"-#pi"); l.DrawLatex(-pi/2,yl,"-#frac{#pi}{2}"); l.DrawLatex(0,yl,"0"); l.DrawLatex(pi/2,yl,"#frac{#pi}{2}"); l.DrawLatex(pi,yl,"#pi"); }

Great! Thanks for the help.