TPalette (Z axis) title

I think this is sort of a bug, but I am not sure.

It is not easy to update histogram’s palette axis title, etc. Please find attached a canvas with a histogram, that has title of Z axis set to “aaa”. If you draw the canvas, no title is drawn near to palette axis and the palette is misplaced. If you redraw the histogram with “colz” options, nothing changes. If you redraw first with no options (Draw()) than with “colz”, title of the Z axis appears and the palette is properly placed.

This is a little bit annoying and one has to know that trick to make it work :slight_smile:
pars5_test.root (381 KB)

When I draw your canvas using the latest root trunk on my Mac I get the title on the palette.

With “czer->Draw()”? OK, My version is I guess about one month old trunk, so I’ll recheck.

With "czer->Draw()"?


With the latest trunk the title is drawn properly, but the palette axis is misplaced. Try czer->Draw(), than psf1->Draw(), than psf1->Draw(“colz”) and then the axis is placed correctly. psf1->Draw(“colz”) only does not properly place the palette.

I do not see what is not “correct”. Can you post a picture showing the incorrectness ?
Also, a small script reproducing the problem would be better than explanations.

I attach 3 pictures generated by the attached script (they are attached in the reverse order to what is generated in the script). You can see, that on the last plot the palette is bordering with the histogram, as is the default behaviour when drawind a new histogram with “colz” option. When some operations with canvas are made, like chaning the margin, the palette is not always moved properly. As you can see, redrawing the histogram with the “colz” option does not help - I need to redraw with no options, update the canvas to make sure it was drawn, then redraw with “colz”.
forum_test.C (343 Bytes)

Yes it looks like when you draw the histogram with an option different than COLZ, the palette size and position are reset.

Shouldn’t it be the default behaviour when redrawing with “colz” or perhaps redrawing the canvas? Otherwise you need to know this trick to redraw the histogram properly after changing the canvas margins, etc.

My recommendation would be to save the histogram in the file. Not the Canvas.
Like that you will not need the artificial step canvas->Draw() just to load the histogram.

Yes, that’s one solution, but sometimes you’ve got a canvas with multiple items. You wan’t just to get the histogram and redraw it in a different circumstances. It is not that rare…