Tree draw logarithmic axes autoscale gui

Sorry for the weird title.
I tried to put in all the keywords that I think belong to my little problem.

And here the problem comes:
I am trying to draw a simple graph that uses some columns of the
tree as the x-axis and the y-axis.

To do this, I use exclusively the gui, opening a browser,
loading the tree, putting the variables that I want to plot into the
x and y expression fields.

Then I hit the draw button and everything is displayed as it should.
Very happy with that.
The problems start when I try to modify this graph.
Let’s say I want to plot the points just in a yrange with 10<y<100.
I therefore use the “SetRangeUser” dialog box that appears in the option list that when I use the right mouse button on the y axis.
I do this, and the axis does display a different range - although not between 10 and 100, but between 0 and 210 (approximately).

I have no idea why.

Stranger things happen when I try to plot the plot in a logarithmic scale.
I just tick the “log” option, and the axis does go to log scale as it should.
However, the yrange displayed is now from 200 to 9000.
Mouse interactive Zooming and setrangeuser seem only to be able to change the display within this range. No idea why.

The x axis in logarithmic scale displays the same problem:
once ticking the log tick box, the min/max values of the displayable range seem to be fixed, and mouse zooming and setrangeuser change
the range only within this predefined range that seems to get defined when hitting the log tick box.

When I did this, I noticed that the displayable range in log mode seems to be independent of the range that has been displayed in linear mode before ticking the log tick box.

I have been looking for an autoscale option, but I didn’t find any.

Sorry that I cannot provide a script reproducing the problem, as this question only addresses gui problems.

I am more than wiling to upload my little tree that was used for the drawings though.
tree.root (110 KB)

I am looking at it. I’ll let you know.

SetRangeUser convert the range you give in user coordinates into bin values and then call SetRange which works on bin number. The value 10 and 100 are both in bin number one in your case. So what is displayed is the range of the bin number 1.

The Y axis start at 0. Which is no valid in case of long scale. In that case the lower value of the axis become 0.001 of the maximum axis’ value.

To cure these problems you should define your own 2D histogram (with a good number of bins and axis range) as explained here:
root.cern.ch/root/html/TTree.html#TTree:Draw (the operator >> in the draw command)

Thanks for the reply.
Given my tree in tree.root.
what kind of command-line should I use for plotting in order
to make the axes zoomable in logarithmic mode?
Could you give me an example command line adapted to the tree.root file?

And, given that I look at the file using the gui, and I visualize the
entries of the tree using the gui, (treeviewer), what should I do
if I want to display the entries of the tree in such a way that the zooming
works as one would expect in both linear and logarithmic scales?

Thanks a lot!

{
   TFile f("tree.root");
   tree.Draw("data.x0:data.x1>>h(100,0,9000,100,0.001,150)");
}

I see.
You specify the necessary binning requirements for the histogram
in the drawing command line.
Didn’t know you could do something like this.

Is there a way to use the treeviewer, plotting the contents of my tree.root,
and still have zoomable axes?
Or is there always a pipe to a default histogram, such that I cannot
zoom the axes?
How could I achieve this without knowing the actual necessary
requirements for the histogram (If, for example, I generate
a TGraph using the data in the file, I do not need to know anything
such as number of bins…; so, there maybe a way to generate a TGraph
by some kind of action using the treeviewer?)

You can zoom any axis pressing the left button of the mouse on the minimum point and releasing it at the maximum point.
You can unzoom with the axis context menu “Unzoom”.

Another possibility is to use the graphics editor. To activate the graphics editor, activate “Editor” in the canvas “View” menu.
eg do

tree.Draw("y:x>>h2"); then point to the histogram in the canvas. You will see the histogram editor menu in the editor. Select the “Binning” tab in the editor and play with the various sliders. You can change
-the xmin,xmax of any axis
-the bin offset for each axis
-many other things.
Whenever you move the mouse on a slider, the Tree is re projected to the histogram with the current setting.
This works for 1d and 2d histograms.
see example
Rene


Hi Fons,

thanks for the help regarding the gui.
I am still struggling though.
Using my tree.root file as the input, and plotting x0:x1,
I do see the points that are contained in the tree.
After checking “can edit histogram”, I am also presented
with the binning tab in the editor.
There are, however, two objects in this canvas. One is my histogram,
rebinning of which is crucial to get the axes range on a log log plot
approximately correct; the other one is a tgraph.
The TGraph object is seemingly responsible for the points in the plot.
Just for a starter, I do not seem to be able to change the settings such that
my data points would display a y axis range from 10^-4 to 10^4.
Even though the y axis range in the binning tab claims to start at 0 (which doesn’t really make sense in the log-log view), the value is closer to 2*10^-3.
The number of bins doesn’t seem to change this. The number of bins in the binning tab seems to be determined by the range that I can choose int the slider called y in the Axis Range section of the Y-Axis section.
I do not seem to be able to choose more than 1000 bins though.
The rebinning option of the histogram does not seem to change anything, after choosing 200 in the dialog, the binning tab still displays 1000 bins for the y axis and 160 bins for the x axis.

I am not sure at all what these bins actually mean.
I do understand that the entire range of the axis is divided into segments of the size of every bin, and that zooming is only possible in units of these bin-sizes. The bin edges seem always to be distributed linearly.
What I don’t understand, is, that I am not displaying any histogram at all: I do see all my 4095 points (rather, I would see them if I would be able to choose the axis ranges as I would like to), regardless of the binning options I choose. No sorting of points in bins is taking place anytime. Any point displayed corresponds to a pair of x0,x1 points as given by my tree. And the style of the points I do see is dictated by the style of the TGraph object.

I am not sure how the BinOffset fields work and the number fields under the sliders. Sometimes, I can edit these fields, but not with arbitrary numbers. Sometimes, they are changed by some other things, and I don’t understand how that happens.

At the least for the moment, I am uncapable of displaying the points of my tree in some well-defined ranges. For example, I never succeeded in displaying the points in a y-range between 10^-6 and 10^4.
I tried to find out how this works using the users guide, but it is very short
on the gui points. I constantly have the feeling that there must be very
easy solutions to doing what I want to do, and perfectly logical explanations why the values that I type in are not accepted, or change constantly,
but for now, I am just completely lost.

If you want to force the range of the graph to be

0<x0<1 1e-4<x1<1e2 do

TCanvas c1; c1->SetLogy(); mytree->Draw("x1:x0>>myhist(50,0,1,50,1e-4,1e2)");
Rene (and not Fons)