Hi again,
Thank you to everyone for your suggestions - we have tried them
in a macro and they work. However, if we try and do the following in a
C++ program, it does not work:
// this array gets filled with the names we want to use to label the axis
TString names[100];
// this is the histogram we want to label
funnel = new TH1D("funnel","funnel",14,0,14);
// labelling the axis
for (int i=0;i<20;i++){
funnel->GetXaxis()->SetBinLabel(i+1,names[i+30]);
}
when the code is compiled we see the following error:
passing `const char *' as argument 2 of `TAxis::SetBinLabel(int, char *)'
discards qualifiers
Can anyone tell us what we are doing wrong ?
Thanks :)
All the best
Jo.
******************************************************************************
Jo Cole
ZEUS Collaboration Dept. of Physics
DESY, Rm 1a/244 University of Bristol
email: coleje@mail.desy.de
Tel: 00 49 40 8998 2609
Fax: 00 49 40 8998 3092
******************************************************************************
---------- Forwarded message ----------
Date: Wed, 28 Aug 2002 16:18:48 +0200 (CEST)
From: Stanislav NESTEROV <Stanislav.Nesterov@cern.ch>
To: Joanne Elise Cole <coleje@mail.desy.de>
Subject: Re: [ROOT] HLABEL equivalent in ROOT
Hi Joanne,
I think there is no exact equivalent, but for any type of axis you can
assign to certain bin a character name:
TAxis::SetBinLabel(Int_t nbin,char* label)
Set label for a bin
and
TAxis::LabelsOption(Option_t *option)
Set option(s) to draw axis with labels
option = "a" sort by alphabetic order
= ">" sort by decreasing values
= "<" sort by increasing values
= "h" draw labels horizonthal
= "v" draw labels vertical
= "u" draw labels up (end of label right adjusted)
= "d" draw labels down (start of label left adjusted)
To use them for example with 1-d histogram you can do something like
this:
TH1F ga("ga","Gauss",100,-3,3); //create histo
ga.FillRandom("gaus"); // and fill it
for (Int_t i=1;i<ga.GetNbinsX()+1;i += 10) // Every 10th bin
ga.GetXaxis()->SetBinLabel(i,Form("name%d",i)); //name as "name.."
Best regards
Stanislav.
On Wed, 28 Aug 2002, Joanne Elise Cole wrote:
> Hi,
>
> We are trying to change the axis labels of a histogram in ROOT to be
> names, rather than numbers. If we were using HBOOK, the routine we
> would want to use would be HLABEL - what is the ROOT equivalent ?
>
> Thanks.
>
> All the best
>
> Jo.
>
> ******************************************************************************
>
> Jo Cole
>
> ZEUS Collaboration Dept. of Physics
> DESY, Rm 1a/244 University of Bristol
>
> email: coleje@mail.desy.de
> Tel: 00 49 40 8998 2609
> Fax: 00 49 40 8998 3092
>
> ******************************************************************************
>
>
>
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:06 MET