I am new to root. I can plot two TGraphErrors on the same axes with the code below and set the range of the x-axis with the gr1->GetXaxis()->SetLimits( 3660, 3700); statement. But when I try to do the same thing for the y-axis nothing happens, although I don’t get an error message, the axis keeps the same range displayed. Can someone tell me how I can set the y-axis range?
TGraphErrors* gr1 = new TGraphErrors(n, cm_energyMeV, scaled_xsec, 0, scaled_xerr);
gr1->SetTitle("Cross-Section at the #psi '");
TGraphErrors* gr2 = new TGraphErrors(j, nk_cm_energyMeV, nk_scaled_xsec, 0, nk_scaled_xerr);
gr2->SetTitle("Cross-Section at the #psi '");
gr1->GetXaxis()->SetLimits( 3660, 3700);
gr1->GetYaxis()->SetLimits( 0, 1900);
I can reproduce this with 2 TH2Fs in one Canvas (one pad each), rightclicking on the yaxis, SetRangeUser - and nothing happens. 1FH2F per canvas works just fine. CVS version from last week, linux build=debug.
Use SetMinimum/SetMaximum for the axis corresponding to the data.
TGraph and TH1 behave in the same way.
Thanks your Root supporting.
SetRangeUser and SetLimits can not zoom Yaxis of TGraph as
shown in an attached eps file that is obtained by
the sample code at the following condition:
Root Version 4.00/06 11 August 2004
CINT/ROOT C/C++ Interpreter version 5.15.138, May 23 2004
Linux version 2.4.19-0vl11
gcc version 2.95.3
testrange.c (443 Bytes)
You should call
gr->GetYaxis()->SetRangeUser( 3, 8 );
I will add support for SetRangeUser for the Y axis in a coming version to get more symmetry with the x axis.
Thank you for your quick response.
I will select data-points for SetPoint() by myself until
your symmetry axis X-Y version.
Adding selection codes may be easy to user, however your new
version will increase functionality of TGraph in
browsing and data selection.
Now implemented in the CVS version