Drawing TH1 with errorbars AND line?

Dear ROOTers,

I encountered a problem when trying to plot a 1D histogram.
Before attaching errorbars, the data points get connected when drawing the histogram with the option “L”. This is shown as the green curve in the attached picture.
But as soon as I am attaching errors to the bins and trying to get these drawn, too, the line connecting data points gets lost. You can see this in the picture: There are red errorbars but there is no red line connecting the points.
Why?

Thanks,

Moritz
errorbar-problem.C (224 Bytes)


I cannot reproduce this problem.
In case you are using an old version, I can only suggest to try with the current production version 5.18

Rene

Hi,

thanks for looking into this.

I am already using the latest production version (root 5.18/00) under Win32 (Vista). Sorry for not having said this before. The sample macro reproduced the same result under Windows 2000 with root 5.14/00.

The problem persists even if I disable all of my startup scripts, styles, etc. by using the command-line option “-n”.

When working with the editor window interactively, I noticed the drop-down box “Style” offers me nothing but “No Line” if anything other than “No Errors” is selected in the “Error” box.

So, is this “no line if errorbars are drawn” rule an intended limitation? (If yes: Why?)

Moritz


In your original script I do not understand why you are setting the line color to 8, then call DrawClone. If you simply want to connect the points and also have the error bars, do:

[code]{
TH1D* h = new TH1D(“test”, “Histo illustrating line & errorbar problem”, 15,-1,1);
h->FillRandom(“gaus”, 1E5);

h->Sumw2();
h->SetLineColor(2);
h->Draw("E1");
h->Draw("SAME Lhist");

}
[/code]

Rene

This script was just meant to illustrate the problem. What I wanted to show is that the drawing options “E1” and “L” seem to be incompatible.

But you already gave me the solution: I have to do draw the histogram with errorbars and the line (re-appearing with “L Hist”) in successive steps.

I still don’t understand why Draw(“E1 L”) does not give me a line, but never mind, the workaround works.

Thank you!

Moritz