Histogram GetListOfFunctions empty

Hello dear ROOT-users,

please consider the following macro:

void test(){
TH2F* hist = new TH2F(“hist”,“hist”,100,0,100,100,0,100);
hist->FillRandom(“gaus”);
hist->Draw(“COLZ”);
hist->GetListOfFunctions()->Print();
}

When executed in a root file (test.C) in interpreted or compile mode, it prints an empty list, whereas if I execute the lines one-by-one in the root shell, it prints the proper list of objects, containing the TPaletteAxis.
Why is this and how can I achieve obtaining the proper list also when executed as a macro?

Regards,
Carsten

After “hist->Draw” add:
gPad->Modified(); gPad->Update(); // enforce physical drawing

It works perfectly, thanks!