Save as root macro produces a different image

The “save as” root macro ignores several settings, currently I have noticed ROOT.gStyle.SetEndErrorSize() and ROOT.gStyle.SetHatchesLineWidth(). It also produces the wrong axis label sizes (one needs to compare carefully, but they are still noticeably different), however this I only observe with a label size of 0.04, if I put 0.05 or 0.03 for example, then the generated macro file produces the right axis label sizes, which is strange.

The images I get with running the script in python, and later doing root test.C are shown below in the same order. My questions are, do you also observe these problems and are these bugs that can be fixed? There could be some other settings that the save as root macro ignores (some of them I posted about earlier this week, they are now fixed).

import ROOT

ROOT.gStyle.SetEndErrorSize(20)
ROOT.gStyle.SetHatchesLineWidth(4)

graphs = ROOT.TMultiGraph()
canvas = ROOT.TCanvas()

graph = ROOT.TGraphErrors()
graph.SetPoint(0,3,2)
graph.SetPointError(0,0,1)
graph.SetLineWidth(4)
graphs.Add(graph, "p")

graph2 = ROOT.TGraphErrors()
graph2.SetPoint(0,4,2)
graph2.SetPointError(0,0,1)
graph2.SetPoint(1,5,2)
graph2.SetPointError(1,0,1)
graph2.SetFillStyle(3490)
graph2.SetFillColor(ROOT.kRed)
graphs.Add(graph2, "3")

graphs.Draw("A")

axisX, axisY = graphs.GetXaxis(), graphs.GetYaxis()
axisX.SetLimits(2.5,5.5)
axisX.SetLabelSize(0.04)
axisY.SetLabelSize(0.04)

canvas.Modified()
canvas.Update()
canvas.SaveAs("test.png")
canvas.SaveAs("test.C")


ROOT Version: 6.19.01
Platform: Ubuntu 18.04
Compiler: gcc 7.4
Python: 3.6.8


Hi,

@couet can surely have a look.

This case is different. You change the line width hatches with gStyle that’s a general setting which is not save in the macro when you save it as a C file. You should set:

   gStyle->SetEndErrorSize(20);
   gStyle->SetHatchesLineWidth(4);

Before executing test.C. Or put that in your rootlogon.C file

If the save as root macro is not supposed to have the same hatches and error bar end sizes, then ok.

However, the axes label sizes difference problem I still have, do you also get the same problem?

I do not see the size problem. Here are attached the two macro. The original one and the saved one. On both files the label size for the multigraph is 0.05.kihjos4.C (836 Bytes) test.C (3.8 KB)

With label size 0.05 it works for me too, however, if I put label size 0.04, then the saved as macro doesn’t have multigraph->GetXaxis()->SetLabelSize(); at all in it, and then it looks different. kihjos4.C (836 Bytes) test.C (3.8 KB)

Now fixed. Thanks to have seen it.

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