Position of error bars - edit possible?

Hi all!

A quick (and probably rather dumb) question from me: In a 1D histo, is it possible to change the X-position where ROOT draws the error bars of the histo?

Why I ask: I’d like to plot three histograms (each corresponding to a different sample) on top of each other. The binning is the same for each (and therefore the bin centers are naturally the same). It’s essentially a consistency check, so the bin contents of the histos are very close to each other, much below the error, and if I plot the error bars, they essentially lie on top of each other and it’s barely possible to distinguish anything. The “e2” option, where small lines are drawn at the end of the error bars, helps a little, but not that much.

Now, if I could simply shift the position where the error bar is being drawn it would be perfect. Right now however the only chance I could come up with is to shift the bin borders slightly for each histogram - since the “true”, physical binning is identical this would look a bit weird however.

Thanks a lot in advance!
Cheers, Wolfgang

For histograms the errors are always painted in the bin center. To distinguish them you can play with the line width, color etc (just an idea…). Using TGraphErrors allows to place the bars exactly where you want. Do you have a small macro reproducing the effect you see ? I can try to improve it …

Thanks! TGraphErrors might really be just the way to go, I’ll take a look at it.

As for a macro - I wrote a quick ten liner producing such a situation, it’s really quite trivial, actually. :slight_smile:

TH1D* histo1 = new TH1D(“histo1”, “histo1”, 3, 0,3);
TH1D* histo2 = new TH1D(“histo2”, “histo2”, 3, 0,3);
TH1D* histo3 = new TH1D(“histo3”, “histo3”, 3, 0,3);
TRandom3 random(0);
for ( int bin=1; bin<=3; bin++ ){
histo1->Sumw2(); histo1->SetLineColor(kGreen);
histo2->Sumw2(); histo2->SetLineColor(kRed);
histo3->Sumw2(); histo3->SetLineColor(kBlue);
histo2->Draw(“e1 same”);
histo3->Draw(“e1 same”);

Yes TGraphErros is surely the best solution. But have you try to play with the line width ? it may gives good result. You should draw the histogram with the largest line width 1st