Dear experts,
I want to do a very simple thing: plot a histogram in a pad/canvas with fixed label size, label offset, title size, and title offset. Fixed here means I want to give pixel values. Reading through the documentation [1], I found the following lines:
"virtual void SetLabelOffset (Float_t offset=0.005)
Set distance between the axis and the labels The distance is expressed in per cent of the pad width. More…
virtual void SetLabelSize (Float_t size=0.04)
Set size of axis labels The size is expressed in per cent of the pad width. More…"
As I have understood this, one should therefore be able to build the pixel-sized labels and titles a la
padvalue = pixelvalue / (pad.GetWw()*pad.GetAbsWNDC())
I am following what has been explained by Rene Brun in [2].
How can I also set the title offset in pixels?
I tried to do it in an anlogous way but it does not seem to work. The script you can find below as well as two plots that I have made with two different sizes of the pad “p”, done in line 32. Once, I have x in the range 0-1, this is the “big” plot, and once i have x in the range 0-0.5 resulting in the plot denoted “small”, while y always is in the range 0-1. As you see, the x and y titles have different offsets, so I must be missing some term or in general not do it properly…
EDIT: actually, also x axis label offset seems to be different for the two plots.
Margins seem OK but I guess its because they are defined on the canvas rather than the pad.
Thank you for any useful advice!
heico
PS: for the canvas margins I have also tried the following construction:
c.SetXXXMargin(c.PixeltoYYY(ZZZ)) where XXX=(Top,Bottom,Left,Right), YYY=(X for Left/Right and Y for Top/Bottom), ZZZ=the different values as given in the file
This has worked fine for Left and Right (PixeltoX) but PixeltoY always has returned 0.1 for whatever value I have entered!
I’m using ROOT v6.08 on MacOSX 10.12.16.
[1] - https://root.cern.ch/doc/master/classTAttAxis.html
[2] - https://root.cern.ch/root/roottalk/roottalk97/1194.html
code:
test.py (1.6 KB)
“big” plot (x 0-1):
“small” plot (x 0-0.5):