Font size for histogram


Dear all,
I am modifying the my histogram options.
I have been asked to make. to histogram with a wide of 8.5 cm and the font size inside the histogram (axis title and labels) around 2 mm.

but I can not figure out how to fix this. since the font size with root is something relative to the canvas size.

for instance I used

TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",0,0,500,500);

and
h0->GetXaxis()->SetTitleSize(0.07);

How can I convert these relative numbers into absolute number?
so I can change the canvas width into 8.5 cm and the title size into 2 mm

Cheers

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Use pixel font (precision=3).

SetTextFont(43);
SetTextSize(15);

Dear
Thank you for your reply

I tried both

gStyle->SetTextFont(43);
gStyle->SetTextSize(15);

gStyle->SetLabelFont(43);
gStyle->SetLabelSize(15);

But the size of the font stil relative to the canvas size.
Please, I want the final canvas size 8.5 cm and the font size 2 mm as fixed numbers
not relative to each other.
is there a way to do this??
and is the font size (15) equal to 15 pixel??

cheers

Can you post some macro showing the problem ?

  TCanvas *c1 = new TCanvas("c1","A Simple Graph Example",0,0,500,500);

   
  // c1->SetGrid();
   gStyle->SetOptTitle(0);
   gStyle->SetOptStat(0);
   gStyle->SetTextFont(43);
   gStyle->SetTextSize(15);

   gStyle->SetLabelFont(43);
   gStyle->SetLabelSize(15);
  // gROOT->ForceStyle();

h0->GetXaxis()->SetTitle("Channel Number");
   h0->GetXaxis()->SetTickLength(0.02);
   h0->GetXaxis()->SetTitleSize(0.09);
   h0->GetXaxis()->CenterTitle();
   h0->GetXaxis()->SetTitleOffset(1);
   h0->GetXaxis()->SetLabelSize(.09);
   h0->GetXaxis()->SetRange(0,1100);
   h0->GetXaxis()->SetLabelOffset(0.005);

Try this:

{
   auto h0 = new TH1F("h0","h0",10,-10,10);
   h0->GetXaxis()->SetTitle("Channel Number");
   h0->GetXaxis()->SetLabelFont(43);
   h0->GetXaxis()->SetLabelSize(30);
   h0->Draw();
}

Grow and shrink the canvas. You will see that all the text on the calvas change size relatively to the canvas size except the X labels axis which are fixed to 30px.

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