Setting Axis Range Ignored When Drawing TF1

I am trying to draw several TF1’s on the same set of axes.

My question title pretty much sums up the problem, the y axis range stays the same whatever I do.

Below is a minimal working example to demonstrate the problem.

void Example(){

  TF1 *f1 = new TF1("f1","x*x + 1",0,1);

  TF1 *f2 = new TF1("f2","x*x + 100",0,1);

 TCanvas *c = new TCanvas("","");

  f1->Draw();

  f2->Draw("same");

 

  //neither of these works
  f1->GetYaxis()->SetRange(0,105);

//f1->GetYaxis()->SetLimits(0,105);

//none of these works

  c->Update();
  //  c->Modified();

  //gPad->Update();
  // gPad->Modified();

}

No combination of SetRange,SetLimits, trying to update the canvas, changing the order of things, changing the draw options etc does anything.

_ROOT Version: 6.18/04
Platform: Not Provided
Compiler: Not Provided


f1->SetMinimum(0.); f1->SetMaximum(105.);

{
   TF1 *f1 = new TF1("f1","x*x + 1",0,1);
   TF1 *f2 = new TF1("f2","x*x + 100",0,1);
   f1->Draw();
   f2->Draw("same");
   f1->GetYaxis()->SetRangeUser(0.,105.);
}

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.