ROOT Version: 6.38.04 From tags/6-38-04@6-38-04
Platform: linuxx8664gcc
Compiler: g++ (GCC) 15.2.0 std202302
I’m creating histograms with custom TColors (provided by ATLAS PubCom, here if you have access). The colors are obtained via GetColor, so colors are shared between histograms instead of creating duplicate colors for each histogram. I then draw my histograms and save my canvases to a ROOT file. Nothing fancy:
ROOT.gROOT.LoadMacro("AtlasUtils.C") # source of myColor()
# ...
output_file = ROOT.TFile(args.output_file, "RECREATE")
canvas = ROOT.TCanvas(hist_name, hist_name, 800, 600)
# ...
hist = input_file.Get(hist_name).Clone(f"{hist_name}_{i}")
color = ROOT.myColor(i, extended_palette)
hist.Draw("HIST")
# ...
output_file.cd()
canvas.Write(hist_name)
However, when loading these canvases for later drawing, something strange happens. Colors do not appear whatsoever until the first canvas saved to the ROOT file is drawn.
I’ve attached an example ROOT file:
plots_m1GeV.root (78.8 KB)
When I execute the following,
root --web=off -b plots_m1GeV.root
h_HNL_Eta->SaveAs("secondplot_before.pdf")
h_HNL_Pt->SaveAs("firstplot.pdf")
h_HNL_Eta->SaveAs("secondplot_after.pdf")
it produces the attached outputs:
secondplot_before.pdf (15.2 KB)
firstplot.pdf (14.7 KB)
secondplot_after.pdf (14.9 KB)
You can see that the second plot is missing colors until the first plot is drawn. I’ve also observed this same behavior in the web-based browser, where the lines appear as a very light gray instead of white.
How can I fix this, or work around this? Or is this a known bug resolved in a later version of ROOT?