Remove vertical errors in marker histogram

Hi,
I want to plot two TH1 superimposed. The histogram with the simulation should have the error band filled, and then I want to represent the horizontal error bar, but not the vertical one. As well, it should be represented with markers, not with a continuous line. I have tried the following:

h_pred->Draw(“e2”);
h_pred->Draw(“e1 same”);

With this I get almost what I want, but it still keeps the vertical line. I saw as possible solutions drawing “hist p”, but I don’t want to have a continuous line, and therefore, I don’t want to use the hist option. I also tried just with the p, as follows:

h_pred->Draw(“e1 same p”);

But it also didn’t work. Any advise is welcome!

Thanks,
Jasone

May be the attached example might help you.
drawhistcustom.C (610 Bytes)

One question about your solution and TExec in general: is it possible to use it in compiled code where ROOT does not know the name of the function “DrawBin” (it might have been mangled to some ABI specific name or could have been removed completely by the linker)? Is it possible to pass a lambda or a std::function - TExec takes just two strings, so the answer is “no” - but is there an alternative?

My solution would be to clone the original histogram, loop over all bins and SetBinError(bin, std::nexttoward(0.0f, 1)); and then simply call h->Draw("same E").

Good question. I have not tried, I just tried with Aclic (root macros compiled before execution) and it works (I had to add the needed include files of course.

Yes. This is an other possibility. The TExec way is more flexible as you can do what ever you want in the DrawBin function.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.