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

From: Colin Bernet (bernet@kph.uni-mainz.de)
Date: Thu Feb 08 2001 - 17:09:27 MET


Hi Jens,

Just do :
histogramm->SetMaximum(ymax);
histogramm->SetMinimum(ymin);

tchuess !

Colin


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);
> 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

--
-------------------------------------------------------------
   Colin Bernet
   Tel. +49-6131/39-23192          Fax  +49-6131/39-22964



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