TMultiGraph.SetMinimum ignored in batch mode

In the following code, the graphs.SetMinimum(0) and graphs.SetMaximum(10) are ignored, if you look at the saved .png image.

import ROOT

ROOT.gROOT.SetBatch(True)

canvas = ROOT.TCanvas("canv0", "Graphs", 0,0,936,860)
graphs = ROOT.TMultiGraph()

graph = ROOT.TGraph()
graph.SetPoint(0,1,1)
graph.SetPoint(1,2,2)
graphs.Add(graph, "l")
graphs.Draw("A")

graphs.SetMinimum(0)
graphs.SetMaximum(10)

graphs.GetXaxis().SetLimits(0,3)

canvas.Update()
canvas.SaveAs("test_graph.png")

This can be fixed either by not running in batch mode, or by setting the x axis limits before the graphs.Setminimum(0). Is it a bug that only in batch mode it demands a certain ordering of the commands?


ROOT Version: current master branch
Platform: Ubuntu 18.04
Compiler: gcc 7.4
Python: 3.6.8


Try: graphs.GetHistogram().SetWhatever(...)

it works for me with :slight_smile:

{
   gROOT->SetBatch(kTRUE);
   auto graphs = new TMultiGraph();
   auto canvas = new TCanvas("c1", "Graphs", 10,10, 1200,800);

   auto graph = new TGraph();
   graph->SetPoint(0,1,1);
   graph->SetPoint(1,2,2);

   graphs->Add(graph, "l");
   graphs->Draw("A");
   auto xaxis = graphs->GetXaxis();
   xaxis->SetLimits(0, 3);

   canvas->SaveAs("test_saveas.png");
}

In the meantime I have recompiled ROOT, and currently the code in the OP no longer produces any problems for me, not sure what was going on.

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