Home | News | Documentation | Download

TH1 Draw Bug: E3 producing same results as E4, E2 also incorrect

Please read tips for efficient and successful posting and posting code

ROOT Version:

ROOT Version: 6.18/04
Built for linuxx8664gcc on Sep 11 2019, 15:38:23
From tags/v6-18-04@v6-18-04


x86_64 Linux (Intel) Debian 10


gcc version 9.3.0 (maybe)

Hi, I seem to have encountered a bug with drawing options and TH1. First off allow me to state that I am not 100 % sure if this is a bug, because the documention only provides a brief discription (text), without example (image).

The documentation I am reading is here: https://root.cern.ch/root/htmldoc/guides/users-guide/Histograms.html#drawing-histograms

Here is what it says regarding the E? options:

  • E1 ”: Draw the error bars with perpendicular lines at the edges
  • E2 ”: Draw the error bars with rectangles
  • E3 ”: Draw a fill area through the end points of the vertical error bars
  • E4 ”: Draw a smoothed filled area through the end points of the error bars

Here are my findings regarding each of these.

E1: Seems to work as expected - or maybe not, see comment below about option “L” (image 1)

E2: I am unsure if I am required to set things such as the FillStyle for this option. Currently I set the SetFillStyle(3002) and SetFillColor(kBlue). It seems to work except for the fact that there is an unexpected mark drawn in the middle of the blue band. (image 2)

If I do not set the FillColor and FillStyle then a dot is drawn. (image3)

I personally do not think this makes sense. If this drawing option requires the FillStyle and FillColor to be set then this should be mentioned in the documentation and if these options are not given then the drawing should either do nothing or fall back to drawing in a default state, such as drawing the same as the “HIST” option. (I can see reasons why that would be confusing however. Perhaps drawing nothing is better.)

Regardless of the above results obtained, the documentation specifically mentions “rectangles”. This isn’t what I would expect to happen given the documentation wording. Essentially, if this is the correct behaviour for E2 then the results obtained with E3 makes no sense. (See below.)

E3: The documentation for E3 states “Draw a fill area through the end points of the vertical error bars”. This appears to be a description of the behaviour seen in image2.

I show the results obtained in image4 and image5. image5 is blank, because I have not set the fill style and color. In this instance it really is blank, and this is the behaviour I would expect to see in the case of E2 also when these options are not set! Seems like a bug/inconsistency.

Regarding image4, this appears to have 2 problems: 1: The spurious dots in the middle have made a return. 2: The shaded area is smoothed! Which appears to match the drawing option description for E4!

E4: Seems to be the same as E3! See image6.

Further issues:

I don’t understand what the drawing option “L” is supposed to do / what the purpose of it is. It appears to do the same thing as “E”. See image7 and image8. Looking back at the text description of “E”, I belive that “E” should draw ONLY the vertical error bar without a horrizontal line, and that the horrizontal line should be added to the error bar option by specifying the combintation of both: “EL”. However for historical compatiability options perhaps there should be a new option for “just the error bar without a line”. Maybe the behaviour is different if one specifies a non-zero MarkerStyle. I don’t know I have not tested this.

I hope these tests are useful. I am surprised to find what appear to be bugs in ROOT 6 regarding drawing options, becuase I would have assumed that someone would have discovered this issue years ago. I find it difficult to beleive that Physicists have been using ROOT for this many years and not reported these as bugs before. This makes me think that it might be me who is wrong, and for some reason I have a misunderstanding and these are not bugs at all. In which case probably the documentation should be adjusted to make it clearer.

Hope the info is useful to a developer, somewhere. All the best!

(Due to new user limitation, I will have to add some of the images in a comment below this post…)

image1: Option: “E1” Problems: Should not have horrizontal line through middle?

image2: Option: “E2” Problems: Should draw some kind of rectangle, not sure if this was the intended result. Some spurious dot in middle of shaded region.

image3: Option: “E2” without setting FillStyle and FillColor. Problem: Dot in middle. Should draw nothing?

image4: Option: “E3”: Draws a smooth region, which is what “E4” should do.

image5: Option: “E3” without setting fill style and color. No issues, “E2” should behave this way when these options are not set.

image6: Option: “E4”. Does same thing as “E3” but in this case the documentation matches the result. (Smooth region)

image7: Option “L” Problem: Same as option “E”.

image8: Option “E”. Problem: Draws horrizontal line, which is what “L” should do?

Final comment: It could be useful to have an option for drawing a solid line above and below the shaded region in the case of option “E3” and “E4”. This would draw a shaded region with the fill style and color specified, and then a line bounding this region using the line color and line style, or possible line style and fill color?

Then this should be able to be combined with “HIST” to draw a line through the middle as well, so that the central value is clearly visible. I will add an image to demonstrate when I have completed this.

Something like this? Possibly this is too specific and every Physicist will ask for ROOT to include his prefered drawing option as a single option rather than sequence of Draw calls. Perhaps it would be better with markers instead of a central line? Perhaps I withdraw my request on this matter?

By the way! On that above point, here is what I obtain after setting the marker style to 20 and calling “PHISTsame”. (image10) This also doesn’t make any sense, because I called HIST and yet there is no HIST line drawn!

Then this is the result for “Psame”. It draws error bars… This should be the result of “PEsame” but it is not! (image11)

image10: Options: “PHISTsame” Problems: No HIST drawn!

image11: Options: “Psame” Problems: Error bars are drawn, which should be the result of “PEsame”!

Hi @Birdsall,
Thank you for your detailed report! I think @couet is the right person who can clear your doubts.

Ok further investigation: This is the result of “PLHISTsame”

The L option has now changed from drawing horrizontal lines to lines connecting the points.

This appears to be another inconsistency with the previously observed behaviour?

Right ok: It appears that L only draws a line, and it is a line between points, when the errors of the histogram are set to zero.

The Horrizontal line I saw before appears to be a result of drawing the error bar, and is nothing to do with the “L” option.

Yes exactly, option “L” means “connect the points with a line”