Hello ROOTers,
I'm trying to change the scale the x-axis of a given function using
f1->GetHistogram()->GetXaxis()->SetLimits(a,b) without success, though
randomly filling a histogram with the function and doing
h1->GetXaxis()->SetLimits(a,b) does work (see simplified macro attached) ...
void test_axis_limits()
{
TF1 *haged = 0;
Double_t ptmin = 1.;
Double_t ptmax = 5.;
Double_t A = 330; // mb/(GeV/c)^2
Double_t p0 = 1.72;
Double_t n = 12.4;
Double_t sqrt_s = 130.;
Double_t pt2xt = 2./sqrt_s;
TCanvas *c4 = new TCanvas("pp_130","pp_130",600,600);
c4->SetLogy();
haged = new TF1("haged","[0]*([1]/(x+[1])^[2])", ptmin, ptmax);
haged->SetParameters(A, p0, n);
haged->SetLineWidth(1);
haged->Draw("");
haged->GetHistogram()->GetXaxis()->SetLimits(pt2xt*ptmin, pt2xt*ptmax);
haged->Draw("");
//c4->SetLogx();
c4->Update();
// Now let's try with a histogram ...
TCanvas *c5 = new TCanvas("hpp_130","hpp_130",600,600);
c5->SetLogy();
TH1F *hhag = new TH1F("hhag","hhag",100,ptmin,ptmax);
hhag->FillRandom("haged",1000000);
hhag->Draw();
hhag->GetXaxis()->SetLimits(pt2xt*ptmin, pt2xt*ptmax);
//c5->SetLogx();
c5->Update();
}
Any hints on how to do that ?
Thanks in advance.
PS: ROOT 3.03/08 binaries on RedHat 7.1
david
--
David d'Enterria PostDoctoral Research Scientist
Nevis Labs http://www.nevis.columbia.edu/~denterria
Columbia University, NY mailto:denterria@nevis.columbia.edu
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
PHENIX Group (Bldg 510C) tel: +1 631 344 7053
Brookhaven National Lab, Upton, NY 11973 fax: +1 631 344 3253
http://www.phenix.bnl.gov/~enterria mailto:denterri@bnl.gov
---------------------------------------------------------------------
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:12 MET