Re: : Re: [ROOT] two histograms with two different scales and different origins (Reply to message posted March 5, 2002 by Rene Brun)

From: Jamila Hussain (jamila@phys.columbia.edu)
Date: Thu Mar 04 2004 - 15:25:30 MET


Thanks, Olivier.  I had actually started with modifying the twoscales.C
tutorial, but got the wrong values for the second plot (the minimum value
for the 1st histogram  was zero, and the minimum for the second was
positive, but the 2nd plot also scaled according to zero as minimum).
So, I mistakenly thought this program could not be used if both minima were not
zero.  It turns out that the scale was correct but the values were offset
with respect to the first minimum.  Hence, adding statements such as

Float_t rightmin = hint1->GetMinimum();
Float_t offset = scale*rightmin;
for (i=0;i<=100;i++) hint1->SetBinContent(i,scale*sum[i]-offset) ;

with the scale defined as (gPad->GetUymax()-gPad->GetUymin())/(rightmax-rightmin)

works just fine.

Thanks a lot,
Jamila

On Tue, 2 Mar 2004, Olivier Couet wrote:

>
>  Hello,
>
>  To do what you want it was not the best example to start with, I guess ...
> I have put in attachment one of the root examples (in tutorial) which,
> seems to me, reflects better what you explained in your email.
>
>  Cheers,       Olivier
>
>
>
> On Mon, 1 Mar 2004, Jamila Hussain wrote:
>
> > Hello Rooters,
> >
> > I have tried to produce a plot with the axis of one histogram plotted on
> > the left side of the pad, and the axis of the other histogram on the right
> > side.  Since the scales differ by two orders of magnitude with different
> > minima, I thought to use the TProfile class as below.  However, if I replace
> >
> > h1->Draw();     with h1->Draw("ah");
> >
> > the left axis still plots.  How can I suppress plotting
> > of the y-axis of one of the histograms?  Is the "ah" option designed to
> > work for the TProfile::Draw ?
> >
> >
> > Thanks,
> > Jamila Hussain
> >
> >
> > {
> >    TH1F *h1 = new TH1F("h1","h1",100,-4,4);
> >    TProfile *h2  = new TProfile("h2","pz vs px",100,-3,3,0,20);
> >    Float_t px, py, pz;
> >    for (Int_t i = 0; i < 25000; i++) {
> >      gRandom->Rannor(px,py);
> >      pz = px*px + py*py;
> >      h1->Fill(px);
> >      h2->Fill(px,pz);
> >    }
> >    h1->Draw();
> >    TPad *pad = new TPad("pad","pad",0,0,1,1);
> >    pad->SetFillStyle(4000);
> >    pad->SetFrameFillStyle(4000);
> >    pad->Draw();
> >    pad->cd();
> >    pad->SetLeftMargin(0.2);
> >    pad->SetBottomMargin(0.2);
> >    h2->Draw();
> > }
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
>
> --
> Org:    CERN - European Laboratory for Particle Physics.
> Mail:   1211 Geneve 23 - Switzerland                     Mailbox: J25910
> E-Mail: Olivier.Couet@cern.ch                            Phone:   +41 22 7676522
> WWW:    http://cern.ch/Olivier.Couet/                    Fax:     +41 22 7677155
>



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET