Dear Rooters,
I am trying to change a limits on X axis in the graph, however the limits still stays at the original ordinates. I am sending a short script that illustrate a problem.
Would it be possible to get an advice on this matter?
Thanks,
Victor.
20 June, 2010
test_0.cxx (669 Bytes)
f_burton.root (17.6 KB)
couet
June 21, 2010, 9:01am
2
Thanks for the fast reply ,
However the suggestion is not working.
If you look at the script that I have sent with previous message it uses the same command:
f_gr_burton->GetXaxis()->SetLimits(x11,x2);
where x11 = 112.9125
and x2 = 526.24224
The limits on the X axe does not changed to the above values. They stay as the were in the root file.
Any suggestions?
Thanks,
Victor.
21 June, 2010
couet
June 21, 2010, 3:16pm
4
Sorry, the recipe I sent you was for graphs. Try:
{
Double_t x1 = 480.;
Double_t x2 = 500.;
TFile *tf_in1 = new TFile("f_burton.root","read");
TCanvas *c3 = new TCanvas("c3","c3",200,10,700,500);
TF1 *f_gr_burton = (TF1*)tf_in1->Get("f_gr1;1");
f_gr_burton->SetLineColor(kRed);
f_gr_burton->SetTitle("burton");
f_gr_burton->SetLineWidth(1);
f_gr_burton->GetXaxis()->SetRangeUser(x1,x2);
f_gr_burton->Draw();
}
Hello again,
I slightly modified the code that you have send and it is not working (indicated by '// <— ').
{
Double_t x1 = 110.; // <— change is here!!!
Double_t x2 = 600.; // <— change is here!!!
TFile *tf_in1 = new TFile("f_burton.root","read");
TCanvas *c3 = new TCanvas("c3","c3",200,10,700,500);
TF1 *f_gr_burton = (TF1*)tf_in1->Get("f_gr1;1");
f_gr_burton->SetLineColor(kRed);
f_gr_burton->SetTitle("burton");
f_gr_burton->SetLineWidth(1);
f_gr_burton->GetXaxis()->SetRangeUser(x1,x2);
f_gr_burton->Draw();
}
With this changes the code is not working. So, when limits on axes are within the range (480;500) the code is working.
The question is why it is not working when I change limits to (110;600) range?
Thanks,
Victor.
21 June, 2010
couet
June 21, 2010, 3:54pm
6
True. When the range is wider you should draw a frame using c3->DrawFrame( …) and then you draw the TF1 using the option SAME.
Thanks,
That was very helpful.
I modified code according to your suggestions:
{
Double_t x1 = 110.;
Double_t x2 = 600.;
TFile *tf_in1 = new TFile("f_burton.root","read");
TCanvas *c3 = new TCanvas("c3","c3",200,10,700,500);
c3->DrawFrame(110.,0.,650.,103.,"burton");
TF1 *f_gr_burton = (TF1*)tf_in1->Get("f_gr1;1");
f_gr_burton->SetLineColor(kRed);
f_gr_burton->SetTitle("burton");
f_gr_burton->SetLineWidth(1);
f_gr_burton->GetXaxis()->SetRangeUser(x1,x2);
f_gr_burton->Draw("same");
c3->Update();
}
It changes limits in the drawings.
Thanks again.
Victor.
21 June, 2010
couet
June 22, 2010, 7:44am
8
Ok. You do not need SetRangeUser anymore.