How to change range of TGraph

Dear Rooters
At the time of drawing a graph, I want to set the range in both X-axis and Y-axis in my macro through command.
It is possible by clicking on the canvas and getting TAxis and then SetRange option.
But I want to set the range in my programme.
Please Give me suggestion.

With regards.

   Int_t n=20;
   Double_t x[n],y[n];
   for (Int_t i=0; i < n; i++) {
   TGraph *gr1 = new TGraph (n,x,y);
   TAxis *axis = gr1->GetXaxis();

   axis->SetLimits(0.,5.);                 // along X
   gr1->GetHistogram()->SetMaximum(20.);   // along          
   gr1->GetHistogram()->SetMinimum(-20.);  //   Y     


Meanwhile I was able to do it.
Just one last unrelated thing:
Any idea on how to add an extra pad to an already divided canvas? Imagine I have two columns and want a third one. Iā€™m doing this by clearing the canvas and re-dividing it, but I feel like there should be a more elegant way of doing it.


You can create as many pad placed where you want using TPad, but
the already existing pads will not move automatically to make room for the extra pad(s)