TMultiGraph.GetYaxis().SetLimits() not working properly

Hi all,

I’m trying to make a TMultiGraph in PyROOT but I’m having some problems with the Y axis limits.

mgGraphs[z].GetXaxis().SetLimits(minCoef, maxCoef) # minCoef = -5; maxCoef = 5; It works fine

The problem is that all curves are parabolas. The cHQ1 seems a straight line, but it is not, the inflection point is below y=0.98.

If I draw cHQ1 alone (cHQ1 only is also a multigraph):

I try to change the Y axis range below y=0.85, but nothing changes.

mgGraphs[z].GetXaxis().SetLimits(minCoef, maxCoef)
mgGraphs[z].GetYaxis().SetLimits(0.5, 2)

First: I need to have same Y axis range in all the multigraphs, it does not matter if there is nothing to plot there

And I try to change Y axis in the multigraph with all curves and I get the same as the first picture. Second: why 0.5 < y < 0.98 are not being shown with mgGraphs[z].GetYaxis().SetLimits(0.5, 2)?


ROOT Version: 6.24/06 (I suppose PyROOT uses the same)
Platform: Windows Subsystem for Linux, Debian
Compiler: IDLE


{
   TGraph *g[3];
   Double_t x[10] = {0,1,2,3,4,5,6,7,8,9};
   Double_t y[10] = {1,2,3,4,5,5,4,3,2,1};
   TMultiGraph *mg = new TMultiGraph();
   for (int i=0; i<3; i++) {
      g[i] = new TGraph(10, x, y);
      g[i]->SetMarkerStyle(20);
      g[i]->SetMarkerColor(i+2);
      for (int j=0; j<10; j++) y[j] = y[j]-1;
      mg->Add(g[i]);
   }
   mg->Draw("APL");
   mg->GetXaxis()->SetTitle("E_{#gamma} (GeV)");
   mg->GetYaxis()->SetTitle("Coefficients");

   // Change the axis limits
   gPad->Modified();
   mg->GetXaxis()->SetLimits(1.5,7.5);
   mg->SetMinimum(0.);
   mg->SetMaximum(10.);
}

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