Discussion:
Issue using TH2::SetMinimum with Draw(Option="BOX")
Ron Malone
2014-05-13 20:27:43 UTC
Permalink
Hello all,

I am currently using ROOT v5.34.18 for data analysis in a low-energy
nuclear physics experiment. I am running Fedora 19. As the subject line
indicates, I am struggling with the TH2::SetMinimum() method when using the
"Box" draw option. When I draw a histogram using TH2::Draw("BOX"), it seems
that SetMinimum does not have the effect I would expect.

My understanding is that for a TH2, SetMinimum should set the minimum value
of the z-axis. When the histogram is drawn, bins with contents less than
this minimum value will not be displayed. This is the behavior exhibited
when the Draw command is used with no options. However, when the "BOX"
option is used with drawing, it seems that the SetMinimum command has
little effect.

I have attached a sample macro (boxmin.C) that plots the same histogram in
various ways to demonstrate this. It loads the histogram from the file
boxes.root. There are some comments in the code to help describe what I
expect/desire to happen.

Is there a way to work around this? In the macro, I use a nested for loop
to alter the bin contents to display what I want, but I would prefer not to
do this.

Thank you,
Ron Malone
Olivier Couet
2014-05-15 07:30:19 UTC
Permalink
When you draw an histogram with the option BOX, the minimum is represented
with an empty bin and the maximum with a box filling the whole bin. This mapping
is done form the histogram minimum to the maximum (those you set
with SetMinimum and SetMaximum). This is the case unless the plot is done
using option SAME (to draw on top of an other plot done with BOX). In that case the
minimum and maximum of the the first BOX plot are taken into account to define the
boxes size. As explained here:
http://root.cern.ch/root/html534/THistPainter.html#HP13



-------- Original Message --------
Subject: Fwd: Issue using TH2::SetMinimum with Draw(Option="BOX")
Date: Tue, 13 May 2014 16:27:43 -0400
From: Ron Malone <***@phy.duke.edu><mailto:***@phy.duke.edu>
To: <***@cern.ch><mailto:***@cern.ch>


Hello all,

I am currently using ROOT v5.34.18 for data analysis in a low-energy nuclear physics experiment. I am running Fedora 19. As the subject line indicates, I am struggling with the TH2::SetMinimum() method when using the "Box" draw option. When I draw a histogram using TH2::Draw("BOX"), it seems that SetMinimum does not have the effect I would expect.

My understanding is that for a TH2, SetMinimum should set the minimum value of the z-axis. When the histogram is drawn, bins with contents less than this minimum value will not be displayed. This is the behavior exhibited when the Draw command is used with no options. However, when the "BOX" option is used with drawing, it seems that the SetMinimum command has little effect.

I have attached a sample macro (boxmin.C) that plots the same histogram in various ways to demonstrate this. It loads the histogram from the file boxes.root. There are some comments in the code to help describe what I expect/desire to happen.

Is there a way to work around this? In the macro, I use a nested for loop to alter the bin contents to display what I want, but I would prefer not to do this.

Thank you,
Ron Malone



<boxes.root><boxmin.C>
Ron Malone
2014-05-15 15:47:21 UTC
Permalink
Oliver,

Thanks for your response. What you described is exactly how I thought the
SetMinimum() command and "Box" option should work. Any bins with content
less than the minimum are displayed as an empty bin.

However, this is not the behavior I observe when I use the SetMinimum()
command with the "BOX" option. I have attached a macro (boxes.C)
demonstrating this along with two png files showing the canvases that I see
when I run the macro (in case the issue is with my ROOT version).

The macro creates a histogram and fills most of the bins with weight 50. It
fills some bins in the center with weight 1000. It also removes the
contents of a column of bins to show that an empty bin will display nothing
when plotted.
Then, it plots four copies of that histogram in canvas c1. The first two
(top of canvas) show a simple scatterplot, one with the minimum set at 0
and one with the minimum set at 100. As expected, only the center bins with
contents greater than 100 are displayed. Then, two more copies are drawn
with the box option (bottom two plots). The plot on the left has its
minimum set at 0, the plot on the right has its minimum set at 100. I can
see no difference between the two plots. Al bins are displayed in both
plots. (See boxes1.png for a picture of what I see).

A second canvas is drawn and a two more copies are drawn with the minimum
set at a ridiculously high value (10,000). As I expect, drawing the
histogram with no options with this minimum displays no boxes. However,
when drawn with the box option, all bins are still displayed with the boxes
seemingly rescaled. (See boxes2.png for a picture of my canvases).

The SetMaximum() command behaves as I would expect with the "Box" option.

Forgive me if that is what you described in your previous email and I
simply misunderstood you. But it seems to me that the behavior I see is
different than what you (or the ROOT documentation) describes. Is it
possible that there is something wrong with my ROOT installation that might
cause this?

Thank you for your time,
Ron
Post by Olivier Couet
When you draw an histogram with the option BOX, the minimum is represented
with an empty bin and the maximum with a box filling the whole bin. This mapping
is done form the histogram minimum to the maximum (those you set
with SetMinimum and SetMaximum). This is the case unless the plot is done
using option SAME (to draw on top of an other plot done with BOX). In that case the
minimum and maximum of the the first BOX plot are taken into account to define the
http://root.cern.ch/root/html534/THistPainter.html#HP13
-------- Original Message -------- Subject: Fwd: Issue using
TH2::SetMinimum with Draw(Option="BOX") Date: Tue, 13 May 2014 16:27:43
Hello all,
I am currently using ROOT v5.34.18 for data analysis in a low-energy
nuclear physics experiment. I am running Fedora 19. As the subject line
indicates, I am struggling with the TH2::SetMinimum() method when using the
"Box" draw option. When I draw a histogram using TH2::Draw("BOX"), it seems
that SetMinimum does not have the effect I would expect.
My understanding is that for a TH2, SetMinimum should set the minimum
value of the z-axis. When the histogram is drawn, bins with contents less
than this minimum value will not be displayed. This is the behavior
exhibited when the Draw command is used with no options. However, when the
"BOX" option is used with drawing, it seems that the SetMinimum command has
little effect.
I have attached a sample macro (boxmin.C) that plots the same histogram
in various ways to demonstrate this. It loads the histogram from the file
boxes.root. There are some comments in the code to help describe what I
expect/desire to happen.
Is there a way to work around this? In the macro, I use a nested for
loop to alter the bin contents to display what I want, but I would prefer
not to do this.
Thank you,
Ron Malone
<boxes.root><boxmin.C>
Olivier Couet
2014-05-15 15:53:49 UTC
Permalink
Hi Ron,

Thanks for the details.
I will check.

Olivier


On 15 May 2014, at 17:47, Ron Malone <***@phy.duke.edu<mailto:***@phy.duke.edu>> wrote:

Oliver,

Thanks for your response. What you described is exactly how I thought the SetMinimum() command and "Box" option should work. Any bins with content less than the minimum are displayed as an empty bin.

However, this is not the behavior I observe when I use the SetMinimum() command with the "BOX" option. I have attached a macro (boxes.C) demonstrating this along with two png files showing the canvases that I see when I run the macro (in case the issue is with my ROOT version).

The macro creates a histogram and fills most of the bins with weight 50. It fills some bins in the center with weight 1000. It also removes the contents of a column of bins to show that an empty bin will display nothing when plotted.
Then, it plots four copies of that histogram in canvas c1. The first two (top of canvas) show a simple scatterplot, one with the minimum set at 0 and one with the minimum set at 100. As expected, only the center bins with contents greater than 100 are displayed. Then, two more copies are drawn with the box option (bottom two plots). The plot on the left has its minimum set at 0, the plot on the right has its minimum set at 100. I can see no difference between the two plots. Al bins are displayed in both plots. (See boxes1.png for a picture of what I see).

A second canvas is drawn and a two more copies are drawn with the minimum set at a ridiculously high value (10,000). As I expect, drawing the histogram with no options with this minimum displays no boxes. However, when drawn with the box option, all bins are still displayed with the boxes seemingly rescaled. (See boxes2.png for a picture of my canvases).

The SetMaximum() command behaves as I would expect with the "Box" option.

Forgive me if that is what you described in your previous email and I simply misunderstood you. But it seems to me that the behavior I see is different than what you (or the ROOT documentation) describes. Is it possible that there is something wrong with my ROOT installation that might cause this?

Thank you for your time,
Ron


On Thu, May 15, 2014 at 3:30 AM, Olivier Couet <***@cern.ch<mailto:***@cern.ch>> wrote:

When you draw an histogram with the option BOX, the minimum is represented
with an empty bin and the maximum with a box filling the whole bin. This mapping
is done form the histogram minimum to the maximum (those you set
with SetMinimum and SetMaximum). This is the case unless the plot is done
using option SAME (to draw on top of an other plot done with BOX). In that case the
minimum and maximum of the the first BOX plot are taken into account to define the
boxes size. As explained here:
http://root.cern.ch/root/html534/THistPainter.html#HP13



-------- Original Message --------
Subject: Fwd: Issue using TH2::SetMinimum with Draw(Option="BOX")
Date: Tue, 13 May 2014 16:27:43 -0400
From: Ron Malone <***@phy.duke.edu><mailto:***@phy.duke.edu>
To: <***@cern.ch><mailto:***@cern.ch>


Hello all,

I am currently using ROOT v5.34.18 for data analysis in a low-energy nuclear physics experiment. I am running Fedora 19. As the subject line indicates, I am struggling with the TH2::SetMinimum() method when using the "Box" draw option. When I draw a histogram using TH2::Draw("BOX"), it seems that SetMinimum does not have the effect I would expect.

My understanding is that for a TH2, SetMinimum should set the minimum value of the z-axis. When the histogram is drawn, bins with contents less than this minimum value will not be displayed. This is the behavior exhibited when the Draw command is used with no options. However, when the "BOX" option is used with drawing, it seems that the SetMinimum command has little effect.

I have attached a sample macro (boxmin.C) that plots the same histogram in various ways to demonstrate this. It loads the histogram from the file boxes.root. There are some comments in the code to help describe what I expect/desire to happen.

Is there a way to work around this? In the macro, I use a nested for loop to alter the bin contents to display what I want, but I would prefer not to do this.

Thank you,
Ron Malone



<boxes.root><boxmin.C>


<boxes.C><boxes1.png><boxes2.png>

Loading...