I am experiencing some inconsistencies with gPad->GetUxmin() and gPad->GetUxmax().
When used with a 1d histogram, the (correct) minimum and maximum values of the x-axis are returned. However for a 2d histogram, they seem to return (some sort of?) NDC values rather than the minimum and maximum values of the x-axis.
Here is a minimal example:
The gPad->Update(); line is necessary for the 1d histogram-case to give the correct values. The same command changes the output of GetUmin and GetUmax, however still not to the axes values. I am quite sure that I used these commands before successfully.
Could somebody please advise how to obtain the min and max of the x and y axis in a 2d histogram.
GetUxmin() and GetUxmax() give correct values if using any other drawing option, such as Draw(“cont3z”) or Draw(“colz”).
Is there a way to have a colored contour plot of a 2d histogram and obtain the (correct) min/max values of the axes?
Aside from the fact that the min/max values of the axes are not the correct ones, I assumed that setting a new range of the pad (or canvas) would give me the right frame of reference. This is however not the case. Let me clarify: I would like to get the correct min/max values of the axes in the 2d histogram to ultimately overlay a TGraph onto the 2d histogram. This fails, since ROOT thinks my coordinate system in x and y is ranging from 0 to 1 (or similar), after plotting using the option cont4. The problem disappears if plotting with any other drawing option (cont3, colz etc.)
So maybe I’m missing something?
Thanks couet! It works.
Minor flaw is the segmentation fault which occurs after clicking anywhere on the pad. Also, the histogram cannot be accessed anymore through right clicking on it, as the top layer of the gPad gives details of a TView3D object (the transparent pad I assume?).
Olivier, I believe your macro contains two small errors.
The “y-low” and “y-high” coordinates for the transparent TPad are miscalculated.
See my last post in the “vertical shaded area” thread.
It looked fine you me. But I did not check closely. May be you are right.
Please post here the version you think is correct in order to avoid to jump
from a post to an other.