Drawing TPaletteAxis in a different pad

I am drawing a TH2D with “colz” option. I would like to draw the z-axis in a different pad from the one used for the histogram. I have tried to retrieve the TPaletteAxis from the histogram:

graph2->Draw();
TPaletteAxis* Zaxis2 = (TPaletteAxis*) graph2->GetListOfFunctions()->FindObject(“palette”);

and then

pad2->cd();
Zaxis2->Draw(“colz”);

But this is not drawing anything.

Does anyone have a suggestion for fixing this?

Thanks.

you can move the palette as shown in the following example.
movepal.C (2.4 KB)