Problem with histograms after saving to file

Dear experts,
I have a root program that works well and generates all histograms the way I want; however, if I save them to a root file, all the settings and color schemes disappear. For example, I set
gStyle->SetPalette(109);
but after saving the 2D histograms to the file, non of the settings and color schemes seem to be working.
I read somewhere that closing the file causes this problem, but I didn’t totally understand it. I didn’t try it either. Is it a good practice to not close the root file at the end of program?
Thanks a lot in advance,


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


The palette is not saved with the histogram. It is not part of it (we cannot save the palette in each histogram that will be a too big overhead). You need to set it again when you display the histogram from a file. If you use always the same palette you can set it in you rootlogon.C file.

Hi Couet,
Thank you very much for the help. Can I ask another question? I noticed that when I am working with a big data set, for example analyzing and saving results of 10 million events as a tree to a root file, the tree is saved twice, like outputtree(1) and outputtree(2). And the first tree has less entries. As if root saves part of the data in the first tree, outputtree(1) and for some reason can’t save more and creates a second tree, outputtree(2) and saves all data in that. Second tree has always all the data including the ones in first tree. It is complete. But I don;t know why it creates an incomplete first tree.
Thanks for your help again,

Thanks a lot, That really helped.