I am plotting a 2D histo w/ colz option. The labels on the color axis however are too big. I can easily change their size in the interactive pad way, but would like to have my program do this automatically. All that i really need to do is to get the TPaletteAxis from the canvas which is automatically names “palette”. However i tried :
TPaletteAxis *pal = gPad->FindObject(“palette”);
which runs error free but gives an empty pointer of that class, to which i cannot perform the necessary action.
There must be an obvious way that i can get this palette in order to modify it that i am missing somewhere.
If any one could help me, i would really appreciate it.
Actually, i had though that this worked, because i tested it in root and performed what i wanted.
However, I had forgotten (and forgotten to mention) , that i have to run root in batch mode. This way doesnt seem to work for root in batch mode.
example:
"
root -b
root: TH2F *h = new TH2F("","",10,0,10,10,0,10);
root: h->Fill(3,3);
root: h->Draw(“colz”);
root: TPaletteAxis pal = (TPaletteAxis) (h->GetListOfFunctions()->FindObject(“palette”));
root: pal->GetAxis()->SetLabelSize(.3);
Error: illegal pointer to class object pal 0x0 972 FILE:(tmpfile) LINE:1
*** Interpreter error recovered ***
"
it seems that the palette gets returned as a blank pointer of type TPaletteAxis. I guess that the color axis palette is not accesible in the same when when running in batch mode.
Sorry for wasting your time with the first question, i obviously didn’t know what i was talking about.
Is there a way to do this?
If anyone could help it would be really appreciated.
I suggest you read the chapter about Graphics in the Users Guide or at least root.cern.ch/root/HowtoDraw.html
The objects such as the TPaveStats box or the TPaletteAxis are created only when effectively painting the histogram. Simply calling Draw adds a reference to the list of primitives in the pad.
Before accessing your TPaletteAxis object, you should call
mycanvas->Update();
In an interactive session, this is automatic when you press CR