When drawing a TGraph on a TPad, the range of the TPad axes is set automatically. But sometimes you want to set it by hand, to align several plots, etc. It seems that TPad::Range(…) is the function to call to do this, but it doesn’t do anything. Here is an example code:
TCanvas * can = new TCanvas(“can”, “”, 500, 500);
TPad * pad = new TPad (“pad”, “”, 0, 0.5, 1, 1);
pad->Range(-2, -4, 10, 10);
pad->Draw();
gPad = pad;
float x[5] = {1,2,3,4,5};
float y[5] = {2,6,-1,3,-2};
TGraph * g = new TGraph(5, x, y);
g.Draw(“al”);
The line pad->Range(-2, -4, 10, 10); is supposed to set the range of the pad axes as specified, but it doesn’t do anything. Trying to make this call after Draw() and calling pad->Update() doesn’t help either. Am I misunderstanding something and there is in fact a different way to do this?
Thanks,
Abi