Re: [ROOT] Interactive zooming

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Aug 10 2001 - 22:09:34 MEST


Hi Chris,
An example in the following script

Rene Brun

//file cexec.C
// root > .x cexec.C
// when zooming on the x or y axis of the contour plot
// the projection will automatically be zoomed
TH2F *h2;
TPad *pad2;
TH1D *hp;
void cexec() {
   h2 = new TH2F("h2","h2",30,-3,3,30,-3,3);
   Double_t x,y;
   for (Int_t i=0;i<10000;i++) {
      gRandom->Rannor(x,y);
      h2->Fill(x,y);
   }
   TCanvas *c1 = new TCanvas("c1","c1",10,10,800,500);
   c1->Divide(2,1);
   c1->cd(2);
   pad2 = (TPad*)gPad;
   c1->cd(1);
   h2->Draw("cont");
   TExec *ex = new TExec("ex","cproject()");
   h2->GetListOfFunctions()->Add(ex);
   hp = 0;
}
void cproject() {
   TAxis *xaxis = h2->GetXaxis();
   TAxis *yaxis = h2->GetYaxis();
   Int_t ixmin = xaxis->GetFirst();
   Int_t ixmax = xaxis->GetLast();
   Int_t iymin = yaxis->GetFirst();
   Int_t iymax = yaxis->GetLast();
   if (hp) delete hp;
   hp = h2->ProjectionX("hp",iymin,iymax);
   hp->GetXaxis()->SetRange(ixmin,ixmax);
   pad2->cd();
   hp->Draw();   
}   

On Fri, 10 Aug 2001, Chris Milne wrote:

> Hi there,
> 
> Is there any way to make the scale of one graph automatically change when the 
> scale of a different graph is manually changed.
> 
> i.e I have two graphs, one contour plot, one ProjectionX. If the scale of the 
> contour plot is adjusted by the user I want the scale of the Projection to 
> automatically change.
> 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:57 MET