Segmentation fault when using TPalette

I want to edit the font size of the palette displayed when I plot a 2D histo in colz mode. In the classe TPaletteAxis, they say to do :
TPaletteAxis palette = (TPaletteAxis)h->GetListOfFunctions()->FindObject(“palette”)

The problem is, when I do that, *palette is 0… it does not find the object “palette”

This is a part of my code :
TApplication theApp(“App”,&argc,argv);
TCanvas *c = new TCanvas(“c”,“Canvas”,800,800);
TH2D *h2 = new TH2D(“h2”,“Escape current probability distribution”,iNbinsX,dXmin,dXmax,iNbinsY,dYmin,dYmax);

    for (int i=0; i<vXML.size(); i++) {
            double dX = getDoubleValue(vXML.at(i),cXaxisName);
            vector<double> vY = vCurrents.at(i);
            for (int j=0; j<vY.size(); j++) {
                    h2->Fill(dX,vY.at(j));
            }
    }
    h2->SetStats(false);
    h2->GetXaxis()->SetTitle(cXaxisName);
    h2->GetXaxis()->CenterTitle(true);
    h2->GetXaxis()->SetTitleSize(0.03);
    h2->GetXaxis()->SetLabelSize(0.02);

    h2->GetYaxis()->SetTitle("Current");
    h2->GetYaxis()->CenterTitle(true);
    h2->GetYaxis()->SetTitleSize(0.03);
    h2->GetYaxis()->SetLabelSize(0.02);
    gStyle->SetStatFontSize(0.02);
    gStyle->SetLabelSize(0.02);
    gStyle->SetPalette(55,0);
    h2->Draw("COLZ");
    TPaletteAxis * palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject("palette");
    cout << "palette = " << palette << endl;

on that line, I get : palette = 0

so the pointer is not initialized

After the statement
h2->Draw(“colz”)
add
gPad->Update();

see doc for more details

Rene

Thank you, I tried, and it worked.

However, I find it a little annoying not to be able to change the properties of the palette before drawing the histogram, so I set it as I wanted to and I saved the macro in a .C file. However, when I put this line in my code :
TPaletteAxis * palette = new TPaletteAxis(4.46389,0.860967,4.63141,1.68318,h2);

The compiler refuses to compile, saying :
/home/mboisson/tmp/ccaOjKSg.o(.text+0xd5): In function formatHistogram(TH2D*, char const*)': : undefined reference toTPaletteAxis::TPaletteAxis(double, double, double, double, TH1*)’

I double checked, I have #include “TPaletteAxis.h” in my file.

You should link your application with libHistPainter.so

Experience has proven that it is a bad idea to implement your own
main program. Instead use the standard root.exe and dynamically
link your application.

Rene