Hi Mina,
The parameters of TGraphErrors::ComputeRange must be initialized before
calling the function. This function is called to compute the min/max
of one or more graphs.
I recommend the use of TMath::LocMin and LocMax to find the location of
the min/max of an array in general. For example:
Int_t ixmin = TMath::LocMin(gr->GetN(),gr->GetX());
Int_t iymax = TMath::Locmax(gr->GetN(),gr->GetY());
Double_t xmin = gr->GetX()[ixmin];
Double_t ymax = gr->GetY()[iymax];
Rene Brun
Mina Nozar wrote:
>
> Hi.
>
> I'm producing a postscript file containing many pages, each with nine
> plots in it. Each plot is the outcome of using TGraphErrors. Now, for
> each plot, I would like to draw a line at a fixed
> x range (xmin and xmax are known constants), but at a different y range
> (ymin and ymax change from plot to plot). I've tried to use
> ComputeRange method of TGraphErrors with no
> success, see below please.... Am I doing something wrong?
>
> //==========================================
> float* afMoment = new float[nEntries];
> float* afErrMoment = new float[nEntries];
> float* afMass = new float[nEntries];
> float* afErrMass = new float[nEntries];
> .....
> .... // inside a loop
> ....
> TGraphErrors *gr = new TGraphErrors(nEntries, afMass, afMoment,
> afErrMass, afErrMoment);
> gr->SetTitle(szMom);
> gr->Draw("ap");
> gr->GetXaxis()->SetTitle("m ( #omega #pi^{-} ) [MeV]");
> gr->Draw("ap");
>
> Double_t min_mass, min_h, max_mass, max_h;
> gr->ComputeRange(min_mass, min_h, max_mass, max_h);
> cout << "min_h: " << min_h << "max_h: ' << max_h << endl; ====>
> this line prints zero for min_h and min_max ???? why?
>
> TLine *line1= new TLine(1235,min_h,1235,max_h);
> line1->Draw();
>
> //=========================================
>
> Thanks,
>
> mina
>
> --
> Mina Nozar
>
> nozarm@jlab.org ----- Phone:(757)269-6391 ----- FAX:(757)269-5800
> Thomas Jefferson National Accelerator Facility
> MS 12H, 12000 Jefferson Ave. Newport News, VA 23606
This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:50:41 MET