How to set up the attributes of a palette?

Before setting up the attributes of a palette, the code below was used to get the Axis of the palette,
TPaletteAxis* palette=(TPaletteAxis*)h2->FindObject(“palette”);
but it failed, from the output comment, it showed palette was a nullptr.
but from result file, there is a palette member in TH2D class pointer “h2”, it is shown below:


so how to set up the attributes of a palette?
Please read tips for efficient and successful posting and posting code

ROOT Version: 6.28/04
Platform: Ubuntu 20.04
Compiler: GCC 9.4.0


Hi,

what exactly do you want to do with the palette that you need to get its axis? What is the end goal?

Did you add

gPad->Update();

as stated in the Docs?

@dastudillo , thanks, after implement “gPad->Update()”, everything works well!

@yus , i want to add a title(include physics quantity and units) to the palette.

I don’t think you need to manipulate with the TPaletteAxis for this, you just need to do

h2->GetZaxis()->SetTitle("Energy [GeV]")

@yus , yes, you are right, thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.