# Draw histogram lines with uncertainties

**URL:** <https://root-forum.cern.ch/t/draw-histogram-lines-with-uncertainties/59149>\
**Category:** Newbie\
**Created:** [April 26, 2024, 11:57am UTC](https://root-forum.cern.ch/t/draw-histogram-lines-with-uncertainties/59149 "2024-04-26T11:57:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![JanEric](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/janeric/32/29559_2.png) [@JanEric](https://root-forum.cern.ch/u/JanEric)\
**Post date:** [April 26, 2024, 11:57am UTC](https://root-forum.cern.ch/t/draw-histogram-lines-with-uncertainties/59149/1 "2024-04-26T11:57:20Z")

</div>

Hi, i am trying to draw plots like in Figure 4 [here](https://arxiv.org/pdf/1902.05759).

What i currently have is 3 histograms, one for data with full uncertainties, one for data with stat. uncertainties and one for MC with total uncertainties.

Currently i am drawing them like this (with the indices matching the above order)

```auto
    hists[2].SetLineColor(ROOT.kRed+1)
    hists[2].SetFillStyle(1001)
    hists[2].SetFillColorAlpha(ROOT.kRed+1, 0.5)
    hists[2].SetMarkerStyle(1)
    hists[2].SetMarkerColor(ROOT.kRed + 1)
    hists[2].SetLineStyle(1)
    hists[2].SetLineWidth(1)
    ROOT.gStyle.SetEndErrorSize(5)
    hists[2].GetYaxis().SetRangeUser(0.0, plotmax * factor)
    hists[2].GetYaxis().SetTitleOffset(1.0)
    hists[2].GetXaxis().SetLabelOffset(999)
    hists[2].Draw("E2")
    hists[2].Draw("same PEY0")
    hists[0].SetMarkerSize(1.0)
    hists[1].SetMarkerSize(1.0)
    hists[0].Draw("same P E0")
    hists[1].Draw("same P E1")

```

This results in a plot like this (ignore the ratio plot)

 ![DY_WZ_PtWZ20_DY_WZPtWZ20_UnfoldedDistribution_swapped](https://root-forum.cern.ch/uploads/default/original/3X/d/2/d2bc3bc4a96b4f329c337a16aa774aba0fe0ebbf.png)

This is almost right except that the MC should only have a horizontal line and not a vertical one, and also i would like to connect the individual bins vertically like in the reference figure.

(Also ideally i would like to also get rid of the end bars on the horizontal errors, is there a way to do that?

And alos do make the uncertainty bands dashed?)

ROOT Version: 6.24/00

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [April 26, 2024, 12:49pm UTC](https://root-forum.cern.ch/t/draw-histogram-lines-with-uncertainties/59149/2 "2024-04-26T12:49:25Z")

</div>

Hi,

Thanks for the interesting post.  
I am adding in the loop @couet and @linev who might suggest the optimal way to achieve that.

Best,  
D

---

<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:** [April 29, 2024, 7:47am UTC](https://root-forum.cern.ch/t/draw-histogram-lines-with-uncertainties/59149/3 "2024-04-29T07:47:35Z")

</div>

> [@JanEric](#):
>
> This is almost right except that the MC should only have a horizontal line and not a vertical one

Histogram errors a re vertical Is that what you ar talking about. Can you sen a minimal piece of code reproducing you problem so wee can run it and understand what is your problem ?
