Changing the axis label size in a root file containg a canvas?


I have a TCanvas as a root file, and it contains several histograms drawn on the pads.

Is it possible to change the axis label size for all the pads (and all the histograms) simultaneously, either in GUI or CLI? Currently, I am using the GUI for that and doing it for all the axes one by one.

Thanks a ton

Maybe using TStyle::SetLabelSize() from TStyle? Otherwise maybe @couet can help

Thank You @bellenot, for the super quick response.

I have actually tried

gStyle->SetLabelSize(0.05, "XY")
c - >Draw()
c-> Update()

But it doesn’t seem to have a effect on the label size, I am not sure if this is different than using TSTyle ?

Try to add c->UseCurrentStyle(); before c->Modified(); and c->Update();

Thanks again, UseCurrentStyle() works great.

However, it overrides the existing attributes if the histograms, such as the line color and line width, are the default. Though not a pressing issue as I can change them manually, is it possible to preserve these attributes and only change the label size?

Well, I guess you have to set all the attributes in gStyle, but maybe @couet know better

Can you provide a small script reproducing your problem ? what @bellenot suggested should have worked.

Yes, surely.

Ok I am waiing for a reproducer. One thing you may try, as you plot comes from a ROOT sile, is to use gROOT->ForceStyle(); after having changed the style

Hi, this is the root file containing the canvas.

Just reiterating the issue , with @bellenot help, I am able to set the label size using

root [8] gStyle->SetLabelSize(0.1, "XY")
root [9] Canvas_1->UseCurrentStyle()

However, it overrides the pre-existing linewidth and color of the histogram.

Canvas_1.root (10.5 KB)

Please let me know if you are unable to access/reproducing issues with the root file of the canvas

% root Canvas_1.root
root [0] 
Attaching file Canvas_1.root as _file0...
(TFile *) 0x7fd68f283c40
root [1] gStyle->SetLabelSize(0.1, "XY")
root [2] gROOT->ForceStyle()
root [3] Canvas_1->Draw()

Thank YOu for the solution.

I am able to set the desired label sizes using this.

However, I think this also overrides any previous attributes like LineColor, LineWidth, etc to the default. I think I need to set them manually again after imposing the label sizes.

In my case, when I do the command I sent you, only the text size is change. For instance the red lines are still red.

I couldn’t get this to work in PyROOT

Can you post a reproducer ?

Yes, same for me as well.

However, the line for TH1 was initially Black with a linewidth of 2, which reverted to the default color and linewidth of 1.

For this simple case, I think I can manually change these back, but is there any efficient way of restoring these settings? Or working with Tcanvas root files is not suggested here ?

sorry, this works perfectly. I didn’t declare them at the top of my script.
making the TFrame after doing this fixes the issue. Thanks

If something change on your canvas after ForceStyle , it means it was relying on the current style value. Therefore you need to make sure the default style, when you start root, is close to the one used to create the canvas.