Problem saving a canvas with a custom palette

Hi guys,
I have a problem when trying to save a root file containing a TCanvas with a custom palette.
I’m using a custom macro that works properly. This means that if I load and execute it with:

root [0] .L  my_macro.C
root [1] my_macro()

I get exactly what I want (i.e. a canvas with a histo + some tgraphs and the custom palette).

I also need to save this canvas in a root file, and here comes the problems. When I open this root file and draw the canvas, I get a seg fault and the canvas is drawn without the palette.

Below the lines of code that involve the canvas and palette creation and writing.

void my_macro()
... *lines of code*

   TFile *fout = new TFile(foutname,"recreate");
   TCanvas *c1 = new TCanvas("c1","c1", 1300,600);
   TH2D* h2 = new TH2D("h2","h2",100,xmin,xmax,100,ymin,ymax);


... *lines of code*

   TPaletteAxis *p1 = new TPaletteAxis(xmax-50,ymin,xmax,ymax,h2);


Another strange (at least to me) behaviour is that I get a seg fault also if I try to close the file (i.e. fout-> Close (); ) before the return line.
Can someone explain to me what’s happening?
Thanks for any help!

_ROOT Version: 6.08/00
_Platform: Ubuntu 16.04
_Compiler: g++ 5.5.0

The palette is not saved in the root files that’s known (and wanted). You should redefine it before plotting the histogram (for instance in you rootlogon.C). The set fault is weird though. That should be checked . Do you have a reproducer ?

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