Label size of palette in 2D color plot

I am trying to change the size of the labels on the palette when doing a 2D plot using COLZ option. I’ve tried to use the example on https://root.cern.ch/doc/master/classTPaletteAxis.html, modifying to change the text size. I see no impact. It does change Y2NDC, as shown in the original example, but not the label sizes.

   TCanvas *c1 = new TCanvas("c1","c1",600,400);
   TH2F *h2 = new TH2F("h2","Example of a resized palette ",40,-4,4,40,-20,20);
   Float_t px, py;
   for (Int_t i = 0; i < 25000; i++) {
      gRandom->Rannor(px,py);
      h2->Fill(px,5*py);
   }
   gStyle->SetPalette(1);
   h2->Draw("COLZ");
   gPad->Update();
   TPaletteAxis *palette = (TPaletteAxis*)h2->GetListOfFunctions()->FindObject("palette");
   palette->SetLabelSize(0.15);
   h2->Draw("COLZ");

_ROOT Version: 6.14/02
Platform: Mac 10.13.6
Compiler: default


At the end of your macro, add line
h2->GetZaxis()->SetLabelSize(0.08);

Also you don’t need draw twice, remove your last line of
h2->Draw(“COLZ”);

Thanks. I thought I had tried that as it is an obvious first thing to do, but apparently I did not. It does indeed work.

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