I have a canvas with several TPads and would like all of them to have the same font size for axis labels and titles.
TAttAxis::SetLabelSize say “size is expressed in per cent of the pad size.” How is the pad size calculated? With that knowledge, it should be possible to rescale all labels and titles to the same font size
I’m aware that I could also use some option to fix the size in pixels, but then, everytime someone changes the size of the output file, the whole label adjustment would have to be redone – which I would like to avoid.
In case this matters, I’m currently using ROOT v6.20/06, but might update it in the next weeks.
In pixels, for a canvas c and pad p1, you can do:
p1_height = c->GetWh()*p1->GetHNDC();
p1_width = c->GetWw()*p1->GetWNDC();
and so on.
p1->GetWh() actually calls
c->GetWh(), so you could also do that.
You can also specify the size in pixels if the font has the precision 3.
So do I understand correctly that the pad size in pixels in then simply
p1_height * p1_width
SetTitleFont(43); // Title size in pixel
SetTitleSize(12); // set the title size to 12 pixels
Yes @couet , I’m aware of the option to just specify this in pixels. But that’s not exactly what I want.
The plotting program I’m working on is part of an analysis framework. While the plots have a certain size and aspect ratio now, this is not fixed whatsoever. Someone might e.g. want the plot to have way more pixels, then the font size would need to be adjusted. Yes, I could work around this by inventing some automatic scaling mechanism, but that already exists in the form of setting the font size relative to the pad size. I just want to have a uniform font size across all axis labels and titles in the plot.
So, let me rephrase the question: What is the size of a TPad for purposes of setting the font size of axis titles and labels? I’ve looked for a
TPad::GetSize method or similar, but didn’t see one.
Of course, I’m happy to use some different mechanism to set the font size in a way that it still looks reasonable after changing the number of pixels in the canvas or it’s aspect ratio – for all pads on a canvas.
I see, I understand now. I thought you wanted to have the same text size around several canvases/pads and undoubtedly the easiest way is to use pixels size in that case.
If you do not use the pixel size the labels and text sizes are a percent of the pad size.
I am not sure that helps, but I do not see what to say more. Maybe a tiny running example might help.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.