Hi,
I am trying to make a figure with two different y axis.
I am looking at the twoscales.C example and the other posts on this forum, but I am still having trouble aligning the second axis.
The problem I face, I think, is due to the fact that I have negative values and I cannot understand how to change the axis range.
If I use: TGaxis*axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(), gPad->GetUxmax(),gPad->GetUymax(), -3,rightmax,510,"+L");
the second axis is draw from -3 as I want but it is not aligned with the associated data, nor with the black axis underneath so also the black ticks can be visible, as you can see from the attached figure.
Attached you can find also a macro for a reproduce.
Thanks!!
p.s. I am running ROOT 6.32.02 for macosxarm64, but I get the same results withROOT 6.32.06 for linuxx8664gcc
When you draw a TGaxis you are accessing the low level graphics function drawing axis. Therefore it does not know about the data previously plotted and it does not align automatically on it. The axis labels are correct (according to want you are requesting): they are ranging from -3 to rightmax (close to 4) and the position is also correct (according to want you are requesting). You may want to remove the dark tick on the right (option Tick)
Hi @couet, thanks!
Yes, removing the ticks solves one issue.
I now need to have the red axis to make sense for the red points…if I do not call SetRangeUser on any histo, I think the points are aligned correctly even for the red axis (attached figure) and the axis, correctly, starts at 0 since I use:
TGaxis*axis = new TGaxis(gPad->GetUxmax(),gPad->GetUymin(),
gPad->GetUxmax(),gPad->GetUymax(),
0,rightmax,510,"+L");
My problem is that I have a red point at -0.5 (last bin), which is of course not shown. As soon as I change the axis ranges (even before filling the histogram using either SetMaximum() and SetMinimum() or SetRangeUser() ) and change accordingly the new TGaxis, I go back to the result attached to my initial question.
I cannot then figure out how to set the range I want for the red points histogram, without having a wrong scale.