Re: [ROOT] Zooming a graph

From: Alberto Garcia Raboso (Alberto.Garcia.Raboso@cern.ch)
Date: Thu Mar 13 2003 - 19:40:08 MET


Hi Rene,

It doesn't work. I detail you the code I'm using. I create a lot of 
plots, using the same canvas. First, I initialize it with

TCanvas *pCanv = new TCanvas("pCanv", 200, 100, 1100, 800);
pCanv->SetFillColor(10);
pCanv->SetGrid();

Then I have a lot of if blockas like this:

if (fpEff_PhibBins) {
   fpEff_PhibBins->SetMarkerStyle(2);
   fpEff_PhibBins->SetMarkerSize(0.35);
   fpEff_PhibBins->SetMarkerColor(4);
   fpEff_PhibBins->Draw("PA");

   fpEff_PhibBins->SetTitle(fHistTitle.Data());
   fpEff_PhibBins->GetXaxis()->SetTitle("Bins");
   fpEff_PhibBins->GetXaxis()->CenterTitle();
   fpEff_PhibBins->GetYaxis()->SetTitle("Efficiency");
   fpEff_PhibBins->GetYaxis()->CenterTitle();
   fpEff_PhibBins->GetXaxis()->SetRangeUser(-20, 20);
   fpEff_PhibBins->GetYaxis()->SetRangeUser(0.8, 1.0);

// pCanv->Modified();
   pCanv->Update();
   pCanv->SaveAs( (const Char_t*) ( TString("Eff_PhibBins") + fFileName + TString(".ps") ) );
   pCanv->Clear();
}

Finally, I clear the screen:

delete pCanv;

Neither uncommenting the line with pCanv->Modified() nor using another one 
like you told me in your email, I get the correct plot range... :-(

Alberto

On Mon, 10 Mar 2003, Rene Brun wrote:

> Hi Alberto,
> 
> do:
> 
> theGraph->GetXaxis()->SetRangeUser(umin,umax);
> gPad->Modified();
> 
> 
> Rene Brun
> 
> On Mon, 10 Mar 2003, Alberto 
> Garcia Raboso wrote:
> 
> > Hi ROOTers,
> > 
> > In the User's Guide it is said that to zoom a graph you have to create an 
> > empty histogram with the axis limits you want, and then draw the graph. Is 
> > it possible to draw a graph and then reset the axis limits so as to get it 
> > zoomed?
> > 
> > I mean, I want to first draw the graph, then resize it. I have tried with 
> > theGraph->GetXaxis()->SetRangeUser(), and then theCanvas->Update(), but it 
> > doesn't work. Any idea?
> > 
> > Thanks for your help,
> > 
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Alberto Garcia Raboso
> > Universidad Autónoma de Madrid (Spain)
> > E-Mail: Alberto.Garcia.Raboso@cern.ch
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > Well, farewell, my hobbits! You should come safe to your own
> > homes now, and I shall not be kept awake for fear of your
> > peril. We will send word when we may, and some of us may yet
> > meet at times; but I fear that we shall not all be gathered
> > together ever again.
> > 
> >                       The return of the King. J.R.R. Tolkien
> > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:10 MET