Re: [ROOT] Bin coordinates

From: Michael Wiesmann (wiesmann@e18.physik.tu-muenchen.de)
Date: Fri Jul 04 2003 - 11:16:32 MEST


Marco Ajello writes:
 > Dear all,
 > I have a TH2D contour plot and I want to access the bins coordinates 
 > x and y. How can I do it?
 > Regards,
 > Marco
 > 

Hi Marco!

I don't realy understand what you mean with "access"?

Do you want the BinContent() for a point (x,y)?
(TH1::GetBinContent(TH1::FindBin(x,y))

or do you want the bin centers for a point (x,y)?

x_=h2D->GetXaxis()->GetBinCenter( h2D->GetXaxis()->FindBin(x) );
y_=h2D->GetYaxis()->GetBinCenter( h2D->GetYaxis()->FindBin(y) );


Have a lock at the referene manual under
http://root.cern.ch/root/Reference.html, TH2, TH1

A combination of TH1::GetBinContent(), TH1::FindBin(x,y) and
TAxis::FindBin(), TAxis::GetBinCenter() should help.


Greets
Michael



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