Re: [ROOT] Axis numbers

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Nov 14 2000 - 08:57:07 MET


Hi Marc,
I repeat that I cannot reproduce your problem. I cannot understand your
description of the problem with the axis numbers. You are creating two
histograms with the same binning, you get the same bin labels on the two plots.

Can anybody else reproduces Marc's problem ?
try using the macro below.

Rene Brun

//-----------macro marc.C
TH1F* p_hist_fst;
TH1F* p_hist_last;

TCanvas c1("c1","Control Histograms",10,10,1200,800);

void marc()
{
        p_hist_fst  = new TH1F("bla1","ble",100,0.,100.);
        p_hist_last = new TH1F("bla2","bli",100,0.,100.);


        DrawHist(p_hist_fst);
        DrawHist(p_hist_last);
}


void DrawHist( TH1F* p_hist )
{

        gStyle->SetStatW(0.3);
        gStyle->SetStatH(0.3);

        TPad *pad1 = new TPad("pad1","padje",0.05,0.55,0.45,0.95);

        pad1->Draw();

        pad1->cd();

        p_hist->Draw();
        c1->Update();
}
//-----------end of macro


kamps wrote:
> 
> > -----Original Message-----
> > From: brun@pcbrun.cern.ch [mailto:brun@pcbrun.cern.ch]On Behalf Of Rene
> > Brun
> > Sent: Monday, November 13, 2000 2:47 PM
> > To: kamps
> > Cc: roottalk@pcroot.cern.ch
> > Subject: Re: [ROOT] Axis numbers
> >
> >
> > Hi Marc,
> > I cannot reproduce your problem.
> > You seem to use a complex logic to do simething simple.
> > You have anyhow a scoping problem in your function DrawHist.
> > The TPad pad1 object is automatically deleted when you exit from
> > the function.
> > Is it intended ? may be replacing the line
> >         TPad pad1("pad1","padje",0.05,0.55,0.45,0.95);
> > by
> >
> >         TPad *pad1 = new TPad("pad1","padje",0.05,0.55,0.45,0.95);
> >
> > is more appropriate?
> >
> > Rene Brun
> >
> Yes, it was intended, but I changed the macro according to your suggestion
> and I still saw the same.
> > kamps wrote:
> > >
> > > The following macro displays the two histograms, the axis
> > numbers on the 2nd
> > > one look weird
> 
> This is not a very exact description of the problem, sorry. What I
> see is that the first histogram has axis numbers as expected, i.e.
> 0, 10, 20, 30, etc.
> 
> In the second histogram the axis numbers are 0. 10, 20, 30, 40, 60, 80, 70,
> 80, 90, 100.
> 
> The problem disappears if I increase the labelsize, however (which is not a
> bad idea anyway). Might it have to do with the interpretation of fonts on my
> machine ?
> 
> > > on my machine. WinNt - 2.25/03
> > > Best Regards,
> > >         Marc
> > >
> > >
> > ------------------------------------------------------------------
> > ----------
> > > ----------------
> > > TH1F* p_hist_fst;
> > > TH1F* p_hist_last;
> > >
> > > TCanvas c1("c1","Control Histograms",10,10,1200,800);
> > >
> > > void test()
> > > {
> > >         p_hist_fst  = new TH1F("bla1","ble",100,0.,100.);
> > >         p_hist_last = new TH1F("bla2","bli",100,0.,100.);
> > >
> > >         DrawHist(p_hist_fst);
> > >         DrawHist(p_hist_last);
> > > }
> > >
> > > void DrawHist( TH1F* p_hist )
> > > {
> > >
> > >         gStyle->SetStatW(0.3);
> > >         gStyle->SetStatH(0.3);
> > >
> > >         TPad pad1("pad1","padje",0.05,0.55,0.45,0.95);
> > >
> > >         pad1->Draw();
> > >
> > >         pad1->cd();
> > >
> > >         p_hist->Draw();
> > >
> > >         c1->Modified();
> > >         c1->Update();
> > >
> > >         char bla[10];
> > >         printf("Type something to see nxt histo\n");
> > >         scanf("%s",bla);
> > > }
> >



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:37 MET