Changing the Z axis title in TH2 after drawing


I’ve encountered a problem with changing the Z axis title in TH2’s not being propagated to the canvas when drawing. If one creates and draws a TH2, setting some Z axis title, then it seems that if the title is changed, subsequent attempts to draw the TH2 will retain the old title. Even when the histogram is saved to file, and retrieved, the title does not update. A cloned histogram retains the wrong title even if the title is changed before cloning.

It seems like this is happening because the TH2 retains a TPaletteAxis which in turn holds a TGAxis, whose title is set when the histogram is drawn, but subsequent calls to TH2::SetZTitle(), or TH2::GetHistogram()::SetTitle() do not modify the TPaletteAxis and TGAxis. Only when I deleted the TPaletteAxis did the drawing get the title correct.

This is quite inconvenient, as one might wish to clone a TH2 and change the title after drawing (in this case I create the histogram by drawing out of a TTree) and perhaps modifying it, e.g. dividing by another histogram. Can this please be fixed, or is there some condition under which this does/does not happen?


Reading between the lines I gathered that this problem shows up when you draw with the option COLZ.
I confirm I was not able to change the title. I will check.
With option LEGO or SURF it is fine.

Now fixed in the trunk.
Thanks for reporting.

Yes, COLZ indeed, sorry for not mentioning specifically. Thanks for the fix.