Maximum number of digits in axis label

Hi,
I tried the option TGaxis::SetMaxDigits(2) in one of my TH2F histograms to get rid of the extra digits on the axis labels, it worked but then the color palette was also changed and it now looks funny, is there an option to do the above for the axis labels only.
Also the numbers on the Palette don’t appar all the time, I tried to resize the canva but it didn’t work.
I attache two files, one before the TGaxis being added and one after, I also attach the script.

{
TFile *f1 = new TFile(“histograms_Qs.root”,“READ”);
TCanvas *dtest = new TCanvas(“dtest”,“dtest”,1000,800);
dtest->Divide(2,2,.01,.01);
hAX4nb2PE_P->SetStats(kFALSE);
hAX4nb2PE_Data->SetStats(kFALSE);

//hAX4nb2PE_P->GetXaxis()->SetTitleSize(0.05);
//hAX4nb2PE_Data->GetXaxis()->SetTitleSize(0.05);

//hAX4nb2PE_P->GetYaxis()->SetTitleSize(0.05);
//hAX4nb2PE_Data->GetYaxis()->SetTitleSize(0.05);

hAX4nb2PE_P->GetXaxis()->SetTitle(“CX2 = (nb2/cxPE)”);
hAX4nb2PE_Data->GetXaxis()->SetTitle(“CX2 = (nb2/cxPE)”);
hAX4nb2PE_P->GetYaxis()->SetTitle(“AX4P = (nOut+nTop)*nFit/cxPE”);
hAX4nb2PE_Data->GetYaxis()->SetTitle(“AX4P = (nOut+nTop)*nFit/cxPE”);

hAX4nb2PE_P->GetXaxis()->SetRange(0,60);
hAX4nb2PE_Data->GetXaxis()->SetRange(0,60);

hAX4nb2PE_P->GetYaxis()->SetRange(0,60);
hAX4nb2PE_Data->GetYaxis()->SetRange(0,60);

hAX4nb2PE_P->SetTitle(“Proton MC”);
hAX4nb2PE_Data->SetTitle(“Data”);

//Normailze the histograms

Double_t scale_P = 1.0/hAX4nb2PE_P->Integral();
hAX4nb2PE_P->Scale(scale_P);
Double_t scale_D = 1.0/hAX4nb2PE_Data->Integral();
hAX4nb2PE_Data->Scale(scale_D);

dtest->cd(1);
TGaxis::SetMaxDigits(2);
hAX4nb2PE_P->SetMinimum(1.e-6);
hAX4nb2PE_P->Draw(“colz”);

dtest->cd(2);
gPad->SetLogz();
hAX4nb2PE_P->Draw(“colz”);

dtest->cd(3);
hAX4nb2PE_Data->SetMinimum(1.e-6);
hAX4nb2PE_Data->Draw(“colz”);

dtest->cd(4);
gPad->SetLogz();
hAX4nb2PE_Data->Draw(“colz”);

}
P_D_Dist_After.ps (119 KB)
P_D_Dist_before.ps (117 KB)

I have tried to reproduce your problem with the following macro (I couldn’t use yours because you didn’t send the histogram file):

{
  c1 = new TCanvas("c1","Axis digits",200,10,700,500);            

  hpxpy  = new TH2F("hpxpy","py vs px",40,-40000,40000,40,-40000,40000);

  Float_t px, py, pz;
  for (Int_t i = 0; i < 25000; i++) {
     gRandom->Rannor(px,py);
     pz = px*px + py*py;
     Float_t random = gRandom->Rndm(1);
     hpxpy->Fill(40000*px,40000*py);
  }
  TGaxis::SetMaxDigits(4);   
  c1->SetLogz();
  hpxpy->Draw("colz");
}

With this macro the pallette axis is not affected by the command SetMaxDigits. What is your ROOT version ?

I am sorry, now I attached the histograms file. The root version I am using is 4.00/08.
histograms_Qs.root (198 KB)

What I get is fine. MaxDigits is a global setting which applies on all axis. So it does also apply on the palette axis.