Re: [ROOT] set Y axis limits of a TH1F ??

From: Robert Feuerbach (feuerbac@ernest.phys.cmu.edu)
Date: Thu Feb 08 2001 - 18:51:44 MET


Hi Jens,

For a TH1, you actually want to
  histogramm->SetMaximum(ymax);
  histogramm->SetMinimum(ymin);

The y-axis isn't 'binned' for a TH1, so finding the bin and setting the
range won't help here (however, it would for a TH2).

Good luck,
Rob

On Thu, 8 Feb 2001, Jens Ahrens wrote:

> Hallo
> 
> I write a web-interface to output TH1F histograms of a ROOT file in eps
> format. My cgi script opens a ROOT file , gets a histogram , modifies it
> and then writes it as eps to disc ( ROOT is used for this in batch mode
> ).
> The problem occures when I want to change the of the axis. Everything
> runs fine for the Xaxis :
> 
>  TApplication theApp("App", &argc, argv);
>  gROOT->SetBatch();
> 
> TCanvas *window = new TCanvas("window", "window", 20, 80, 800,600);
> TPad *pad = new TPad ("pad", "pad", 0.00, 0.00, 1.00, 1.00, 1);
> TH1F *histogramm; // the histogram stored in the file has:
>                                        //  xmin=0;xmax=33000;nbins=330
> 
> TFile *f = new TFile("rootfilename","READ","rootfile",9);
>  f->cd();
>  histogramm = (TH1F *)f->Get(histopath);
> 
> Double_t xmin,xmax;
> xmin= // new real coordinates
> ymin= // new real coordinates
> 
> Int_t bxmin=histogramm->GetXaxis()->FindBin(xmin);
> Int_t bymax=histogramm->GetXaxis()->FindBin(xmax);
        ^^^^^
  Int_t bxmax=histogramm->GetXaxis()->FindBin(xmax);


> histogramm->GetXaxis()->SetRange(bxmin,bxmax);
> 
> window->cd();
> window->Draw();
> 
> pad->cd();
> pad->Draw();
> 
> histogramm->Draw();
> pad->Print("epsname","eps");
> 
> f->Close();
> 
> ...html-output....
> 
> But as soon as I want to apply a change to the Yaxis range ( equal
> code)  nothing changes.
> How can I choose the zoom-range of the Yaxis ( in TBrowser it works ).
> 
> Thanks for your effort!
> 
> Jens
> 
> 

-- 
/***************************************************
 * Robert Feuerbach   feuerbac@ernest.phys.cmu.edu *
 * CMU Physics Department           (412) 268-2772 *
 * Pittsburgh, PA 15213        FAX: (412) 681-0648 *
 ***************************************************/



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