Buggy Draw option

Hello everyone!

I observe some weird behavior with Drawing a standard TH1F histogram.

In general I have 3 histograms, of which I want one to be drawn with “HIST” option and the other two as data points above. All are drawn on a 4th template histogram

My starting point was:

h1_one->Draw(“9 SAME HIST”);
h1_two->Draw(“9 SAME”);
h1_three->Draw(“9 SAME”);

This results in a canvas, showing all setting by the empty template histogram and the h1_one entries as HIST style. But h1_two and h1_three Data points are missing.

Dropping the “9” option draws all three histograms with HIST option, no matter if HIST is defined in Draw options or not.

Drawing all three options with the default option Draw("") produces an empty histogram, just showing the template (axis and labels).

Does anyone know about this behavior?


See the description of the available drawing options (in particular “9” and “SAME”) in http://root.cern.ch/root/html/THistPainter.html

Yes I know about these drawing options!

But in particular, the histograms are empty drawing them with default Draw("") and Draw(“SAME”). This is not the normal behavior, right?

Isn’t it explicitly written there for the option “9” … This option should be combined with a “drawing option” like “H” or “L”.
BTW. If you draw all histograms using empty “drawing options” strings, just the last histogram (“h1_three”) will be visible, so what you will get depends on what this histogram actually contains.

Yes thats why I removed the “9” option to check it!

I know I need the SAME option to draw multiple histograms in one Canvas, what I meant with draw option here are options modifying the appearance of the histogram.

The problem is, if I draw it like


I SHOULD get 3 histograms with data points, right? Instead I get three histograms in HIST style, even though I did NOT specify the HIST option!? That is my problem.

Everything depends on what your histograms actually contain.
For example, do they have “errors” or do they not (again, read the description of the “HIST” option).
Or maybe a “default drawing option” for them has been set using TH1::SetOption.

Can you provide a small macro reproducing the problem ?

It is integrated in a larger package. I tried a small macro, but that one was working fine… Here is what I do:

Create the histogram:

TH1F h1_categories = new TH1F(name+"_categories", "", 5, 0.0, 5.0);
  TString labels[5] = {"lab1", "lab2", "lab3", "lab4", "lab5"};
  for(int ilab = 0; ilab < 5; ilab++) {
    h1_categories->GetXaxis()->SetBinLabel(ilab+1, labels[ilab]);

Do some counting experiments and get n_lab1 … n_lab5 and fill:

  if(lab1) h1_categories->Fill(0);
  if(lab5) h1_categories->Fill(4);

Save to a root file. Load the root file in a PlotMaker and plot it with the given Draw options.

How are the errorr here provided or avoided causing the problem?

… ok … that does not help to much to solve your issue…

[quote=“Pepe Le Pew”]Everything depends on what your histograms actually contain.
For example, do they have “errors” or do they not[/quote]

Under which circumstances do they not have errors?

I just solved my issue, I forgot to set:


Now It works fine!

Thanks to everyone!

Good :slight_smile: