How to change the font size of axes labels

Hello,

I want to change the font size of x-axis. I have tried to use SetLabelFont but it does not work.

The code is a follow

void edprocpion()
{
//=========Macro generated from canvas: Canvas_1/Canvas_1
//=========  (Thu Jul 19 10:19:44 2018) by ROOT version6.06/02
   TCanvas *Canvas_1 = new TCanvas("Canvas_1", "Canvas_1",356,215,538,323);
   Canvas_1->Range(-1.5,-2202010,13.5,1.981809e+07);
   Canvas_1->SetFillColor(0);
   Canvas_1->SetBorderMode(0);
   Canvas_1->SetBorderSize(2);
   Canvas_1->SetFrameBorderMode(0);
   Canvas_1->SetFrameBorderMode(0);
   
   TH1F *htemp__2 = new TH1F("htemp__2","edproc.data()",32,0,32);
   htemp__2->SetBinContent(1,3200062);
   htemp__2->SetBinContent(2,1.028411e+07);
   htemp__2->SetBinContent(3,1.677722e+07);
   htemp__2->SetBinContent(4,1.073985e+07);
   htemp__2->SetBinContent(5,2939780);
   htemp__2->SetBinContent(6,60518);
   htemp__2->SetBinContent(7,480825);
   htemp__2->SetBinContent(8,33201);
   htemp__2->SetBinContent(9,473708);
   htemp__2->SetBinContent(10,386725);
   htemp__2->SetBinContent(11,416584);
   htemp__2->SetBinContent(12,124986);
   htemp__2->SetBinContent(13,56999);
   htemp__2->SetBinContent(14,15135);
   htemp__2->SetBinContent(15,23274);
   htemp__2->SetBinContent(16,3966);
   htemp__2->SetBinContent(17,27262);
   htemp__2->SetBinContent(18,1176);
   htemp__2->SetBinContent(19,939);
   htemp__2->SetBinContent(20,3);
   htemp__2->SetBinContent(21,185);
   htemp__2->SetBinContent(22,139);
   htemp__2->SetBinContent(23,33);
   htemp__2->SetBinContent(24,5);
   htemp__2->SetBinContent(25,10);
   htemp__2->SetBinContent(26,17);
   htemp__2->SetBinContent(27,68);
   htemp__2->SetBinContent(28,13);
   htemp__2->SetBinContent(29,11);
   htemp__2->SetBinContent(30,28);
   htemp__2->SetBinContent(31,2);
   htemp__2->SetBinContent(32,1);
   htemp__2->SetEntries(5.521438e+07);
   htemp__2->SetDirectory(0);
   
   TPaveStats *ptstats = new TPaveStats(0.78,0.775,0.98,0.935,"brNDC");
   ptstats->SetName("stats");
   ptstats->SetBorderSize(1);
   ptstats->SetFillColor(0);
   ptstats->SetTextAlign(12);
   ptstats->SetTextFont(42);
   TText *AText = ptstats->AddText("htemp");
   AText->SetTextSize(0.0368);
   AText = ptstats->AddText("Entries =   5.521438e+07");
   AText = ptstats->AddText("Mean  =  2.766");
   AText = ptstats->AddText("Std Dev   =  1.645");
   ptstats->SetOptStat(1111);
   ptstats->SetOptFit(0);
   ptstats->Draw();
   htemp__2->GetListOfFunctions()->Add(ptstats);
   ptstats->SetParent(htemp__2);

   Int_t ci;      // for color index setting
   TColor *color; // for color definition with alpha
   ci = TColor::GetColor("#000099");
   htemp__2->SetLineColor(ci);
   htemp__2->GetYaxis()->SetTitle("Eventos");
   htemp__2->GetXaxis()->SetBinLabel(1,"hIoni");
   htemp__2->GetXaxis()->SetBinLabel(2,"Transportation");
   htemp__2->GetXaxis()->SetBinLabel(3,"msc");
   htemp__2->GetXaxis()->SetBinLabel(4,"eIoni");
   htemp__2->GetXaxis()->SetBinLabel(5,"Scintillation");
   htemp__2->GetXaxis()->SetBinLabel(6,"pi+Inelastic");
   htemp__2->GetXaxis()->SetBinLabel(7,"ionIoni");
   htemp__2->GetXaxis()->SetBinLabel(8,"neutronInelastic");
   htemp__2->GetXaxis()->SetBinLabel(9,"compt");
   htemp__2->GetXaxis()->SetBinLabel(10,"phot");
   htemp__2->GetXaxis()->SetBinLabel(11,"eBrem");
   htemp__2->GetXaxis()->SetBinLabel(12,"hadElastic");
   htemp__2->GetXaxis()->SetBinLabel(13,"Rayl");
   htemp__2->GetXaxis()->SetBinLabel(14,"conv");
   htemp__2->GetXaxis()->SetBinLabel(15,"Decay");
   htemp__2->GetXaxis()->SetBinLabel(16,"protonInelastic");
   htemp__2->GetXaxis()->SetBinLabel(17,"muIoni");
   htemp__2->GetXaxis()->SetBinLabel(18,"annihil");
   htemp__2->GetXaxis()->SetBinLabel(19,"pi-Inelastic");
   htemp__2->GetXaxis()->SetBinLabel(20,"kaon0LInelastic");
   htemp__2->GetXaxis()->SetBinLabel(21,"dInelastic");
   htemp__2->GetXaxis()->SetBinLabel(22,"RadioactiveDecay");
   htemp__2->GetXaxis()->SetBinLabel(23,"nCapture");
   htemp__2->GetXaxis()->SetBinLabel(24,"He3Inelastic");
   htemp__2->GetXaxis()->SetBinLabel(25,"alphaInelastic");
   htemp__2->GetXaxis()->SetBinLabel(26,"kaon+Inelastic");
   htemp__2->GetXaxis()->SetBinLabel(27,"photonNuclear");
   htemp__2->GetXaxis()->SetBinLabel(28,"CoulombScat");
   htemp__2->GetXaxis()->SetBinLabel(29,"lambdaInelastic");
   htemp__2->GetXaxis()->SetBinLabel(30,"tInelastic");
   htemp__2->GetXaxis()->SetBinLabel(31,"kaon0SInelastic");
   htemp__2->GetXaxis()->SetBinLabel(32,"electronNuclear");
   htemp__2->GetXaxis()->SetRange(1,12);
   htemp__2->GetXaxis()->SetLabelFont(42);
   htemp__2->GetXaxis()->SetLabelSize(0.035);
   htemp__2->GetXaxis()->SetTitleSize(0.035);
   htemp__2->GetXaxis()->SetTitleFont(42);
   htemp__2->GetYaxis()->SetLabelFont(42);
   htemp__2->GetYaxis()->SetLabelSize(0.035);
   htemp__2->GetYaxis()->SetTitleSize(0.035);
   htemp__2->GetYaxis()->SetTitleFont(42);
   htemp__2->GetZaxis()->SetLabelFont(42);
   htemp__2->GetZaxis()->SetLabelSize(0.035);
   htemp__2->GetZaxis()->SetTitleSize(0.035);
   htemp__2->GetZaxis()->SetTitleFont(42);
   htemp__2->Draw("");
   
   TPaveText *pt = new TPaveText(0.3957836,0.9351869,0.6042164,0.995,"blNDC");
   pt->SetName("title");
   pt->SetBorderSize(0);
   pt->SetFillColor(0);
   pt->SetFillStyle(0);
   pt->SetTextFont(42);
   AText = pt->AddText("edproc.data()");
   pt->Draw();
   Canvas_1->Modified();
   Canvas_1->cd();
   Canvas_1->SetSelected(Canvas_1);
}

Can you help me with label

   htemp__2->GetXaxis()->SetLabelSize(0.35);

Note that in your macro you set values for the Axis … which you do not have.

3 Likes

Thank you so much I forget that.

I have another concern with regard to how I could eliminate the box where is placed (mean, entries, Std Dev)

   htemp__2->SetStats(0);
2 Likes

Thanks you!!!

Sorry for bother you but I have another question. How can I add
exponents and radicals in a label?

https://root.cern/doc/master/classTLatex.html

2 Likes

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