# Strange behavior with custom TColors in saved TCanvases

**URL:** <https://root-forum.cern.ch/t/strange-behavior-with-custom-tcolors-in-saved-tcanvases/65074>\
**Category:** ROOT\
**Created:** [November 27, 2026, 4:47pm UTC](https://root-forum.cern.ch/t/strange-behavior-with-custom-tcolors-in-saved-tcanvases/65074 "2026-11-27T16:47:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![rmcgover](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/rmcgover/32/26948_2.png) [@rmcgover](https://root-forum.cern.ch/u/rmcgover)\
**Post date:** [November 27, 2026, 4:47pm UTC](https://root-forum.cern.ch/t/strange-behavior-with-custom-tcolors-in-saved-tcanvases/65074/1 "2026-11-27T16:47:56Z")

</div>

* * *

_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 `TColor`s (provided by ATLAS PubCom, [here](https://gitlab.cern.ch/atlas-publications-committee/atlasrootstyle/-/blob/aed963a89317ead8c68401d4bd264dfd89baf48e/AtlasUtils.C#L332) 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:

```py
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](https://root-forum.cern.ch/uploads/short-url/tFeFzdA7viAcuR9RpMiL3ydnfI6.root) (78.8 KB)

When I execute the following,

```cpp
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](https://root-forum.cern.ch/uploads/short-url/ql2clOd0esWgIlaKxyp6n0AANIg.pdf) (15.2 KB)  
[firstplot.pdf](https://root-forum.cern.ch/uploads/short-url/nu8CPzp10t0Pjf67YOeEkaps68m.pdf) (14.7 KB)  
[secondplot\_after.pdf](https://root-forum.cern.ch/uploads/short-url/ituOTGpyv0wW130RlYNrHqwWsui.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?
