Discussion:
[ROOT] alpha numerical axis labels at bin boundaries
(too old to reply)
Sven Menke
2003-09-25 14:27:58 UTC
Permalink
Hi,

it seems that alpha numerical labels on axes are tied to bins. Is there
a way to get alpha numerical labels at the bin boundaries like in the
default numerical case?

I.e. I have a histogram with 4 bins from 0 to 2Pi and would like to
get labels at the tick marks at 0, 1/2 pi, pi, 3/2 pi and 2 pi. The
TAxis->SetBinLabel() method allows for 4 labels only if I have 4 bins
and they are centered at the bins, but in analogy to the default case I
need 5 labels located at the bin edges.

Is there a way to do this?

Thanks,
Sven
Olivier Couet
2003-09-25 16:19:00 UTC
Permalink
Hi,

"Pi axis" need to be implemented in ROOT (in TGaxis). It is not a problem
of labeling, with TLatex it is easy to produce such text. The difficult
part it to optimize properly the tick marks positions according to Pi
divisions. This would require some new developments. To be done.


Cheers, Olivier

PS:

Yes labels are tied to bins but they can be tied to any bins. For example
here is a small example which "tie labels" to one bins every 10 bins:

{
gROOT->Reset();
TCanvas *c1 = new TCanvas("c1","Test",0,0,700,700);
TFile *example = new TFile("hsimple.root","READ");
hpx->Draw();
const Int_t n = 9;
char *nb[n] = {"I","II","III","IV","V","VI","VII","VIII","IX"};
for (Int_t i=1;i<=n;i++) {
hpx->GetXaxis()->SetBinLabel(10*i,nb[i-1]);
}
}
Post by Sven Menke
Hi,
it seems that alpha numerical labels on axes are tied to bins. Is there
a way to get alpha numerical labels at the bin boundaries like in the
default numerical case?
I.e. I have a histogram with 4 bins from 0 to 2Pi and would like to
get labels at the tick marks at 0, 1/2 pi, pi, 3/2 pi and 2 pi. The
TAxis->SetBinLabel() method allows for 4 labels only if I have 4 bins
and they are centered at the bins, but in analogy to the default case I
need 5 labels located at the bin edges.
Is there a way to do this?
Thanks,
Sven
--
Org: CERN - European Laboratory for Particle Physics.
Mail: 1211 Geneve 23 - Switzerland Mailbox: J25910
E-Mail: ***@cern.ch Phone: +41 22 7676522
WWW: http://cern.ch/Olivier.Couet/ Fax: +41 22 7677155
Loading...