Re: 2D histograms and logarithmic axes

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Jan 07 2000 - 16:52:15 MET


Hi Marco,
 To be more positive..

Marco van Leeuwen wrote:
> 
> Hi,
> 
> I have a few remarks regarding 2D histograms. As far as I understand, it is
> still impossible to draw a lego, surface, or contour histograms with a
> logarithmic x or y axis. (By the way, it might make sense to print an error
> message or execute a gPad->SetLogx(0) and gPad->SetLogy(0) instead of
> splashing green an yellow dots all over the canvas.) Furthermore, if you
> use a TH2F with a logarithmic x axis, you would normally prefer to have
> equidistant binning in log x instead of x. For example, if your histo
> ranges from 0.01 to 100, you have to use a 0.01 binwidth in order to have
> some decent results in the low x-range, whereas for the high range 1 of
> even 10 would suffice.

log scales are supported for TH2x objects when displayed in 2-d mode.
When you use the TTree::Draw command, the binning is even computed as
you say
above. This is a well know problem and not so trivial to solve.
The problem is that typically you want to switch between a linear and
log
scale representation and vice versa. At this point you have lost the
original
info (unless the data come from a Tree).
Ah, it was so simple to solve graphics problems at the time of pen
plotters!
Supporting log scale for the 3-d representations is foreseen and we have
been
working recently on alternative axis representations, see below.

>   Having these two in mind, I propose to have a drawing option or TAxis
> switch to draw a logarithmic axis where the axis values are exponentiated,
> i.e. an axis ranging from -1 to 3 will be drawn as a logarithmic scale
> ranging from 0.1 to 1000. If I am not mistaken, this should be fairly
> simple to implement (I even tried to implement this myself, but
> unfortunately the "AH" option is only supported for 1D histograms), and
> have the by-product of solving (at least to first order), the problems with
> the surf and cont options for a 2D histogram. The idea is that you can use
> a histogram ranging from  -1 to 3, fill it with the log10() of your data
> and plot it, displaying axis which make sense for the data.
>
 this option could be implemented, see also below
 
> A second point, which I would like to bring up, is that some people are
> used to also having square-root axes. These have roughly the same effect as
> the logarithmic axes, but behave more smoothly near zero. I wouldn't
> propose to have this supported to the same extent as logarithmic axes, but
> I found that in the specific case of the third axis in 2D-histograms, (i.e.
> the z-axis/the cell-content) this can be far superior to a logrithmic
> scale, expecially when drawing a 'scatterplot'. If other people have the
> same experience, it might be worthwhile to implement this as a standard
> feature of root.

Mathieu de Naurois has recently developed an extension of the class
TGaxis
used to draw TAxis objects. TGaxis has a new constructor where one can
specify a function (TF1) mapping the current user coordinates to the
axis
values and ticks marks. With that one can draw a sqrt(x) scale for
example.
It remains to interface this extension with the current code displaying
the axes.


Rene Brun



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:16 MET