# Error bars are not clear

**URL:** <https://root-forum.cern.ch/t/error-bars-are-not-clear/53793>\
**Category:** Newbie\
**Created:** [February 27, 2023, 12:39am UTC](https://root-forum.cern.ch/t/error-bars-are-not-clear/53793 "2023-02-27T00:39:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dil](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dil/32/26887_2.png) [@Dil](https://root-forum.cern.ch/u/Dil)\
**Post date:** [February 27, 2023, 12:39am UTC](https://root-forum.cern.ch/t/error-bars-are-not-clear/53793/1 "2023-02-27T00:39:02Z")

</div>

Hello Experts,

I’m trying to add the error bars to my histogram. But I do see only the squares with black dot.  
I have weighed histogram by model.Applied sumW2 option before filling the histogram.(At this stage also I see just squares)

Then I need to add separate error for my histogram.

```auto
TH1F h_model_gen //Used 100 bins;
h_model_gen->SumW2();

//fill the histogram
h_model_gen->Fill(mass_pipi, model);
//I haven't seen error bars even in this stage(errors bars from sumW2)

//create another error histogram
error=X
h_error-> Fill(mass_pipi,error);

//Add this error histogram to my h_model_gen histogram

for(int ibin=1;ibin<=h_model_gen->GetNbinsX();ibin++){
                   error_total_1=h_mpipi_gen->GetBinError(ibin);
                   error_total =sqrt(error_total_1*error_total_1+h_error>GetBinContent(ibin));
                   h_model_gen->SetBinError(ibin,error_total);
                   
               }

h_mode_gen->Draw();

```

I don’t see the error bars clearly. Is that because I have 100 bins?  
Please see attached

 ![Screen Shot 2023-02-26 at 7.26.44 PM](https://root-forum.cern.ch/uploads/default/original/3X/6/6/66d7b2508215ab507c2759f12cfac26e86b872c4.jpeg)

Thanks  
Dil

---

<div class="post-metadata">

**Author:** ![hvsouza](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/hvsouza/32/23711_2.png) [@hvsouza](https://root-forum.cern.ch/u/hvsouza)\
**Post date:** [February 27, 2023, 1:54am UTC](https://root-forum.cern.ch/t/error-bars-are-not-clear/53793/2 "2023-02-27T01:54:27Z")

</div>

Dear Dil,

I could not execute the peace of code you provided.

However, here are a few nodes. To [draw a histogram](https://root.cern/doc/master/classTHistPainter.html) with error bars you should do:

```auto
h_mode_gen->Draw("E");

```

(If you want the usual histogram lines, use `hist E` instead)

Here is a quick example:

```auto
TH1D *h = new TH1D("h","h",100,0,1)
TF1 *f = new TF1("f","gaus",0,1); f->SetParameters(1,0.5,0.1)
h->FillRandom("f",5000)
h->Draw("E")

```

Another thing to notice is that your y-axis scales is at `x10^6` it could be that your errors are too small if you don’t see them properly.

Cheers,  
Henrique

---

<div class="post-metadata">

**Author:** ![Dil](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dil/32/26887_2.png) [@Dil](https://root-forum.cern.ch/u/Dil)\
**Post date:** [February 27, 2023, 2:20am UTC](https://root-forum.cern.ch/t/error-bars-are-not-clear/53793/3 "2023-02-27T02:20:09Z")

</div>

Hello Henrique,

Thank you for pointing me out. I guess my y axis is 10^6 and that could be the reason I don’t see clear error bars.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 27, 2023, 8:57am UTC](https://root-forum.cern.ch/t/error-bars-are-not-clear/53793/4 "2023-02-27T08:57:02Z")

</div>

can you provide a reproducer we can run ?
