# 1D histogram questions

**URL:** <https://root-forum.cern.ch/t/1d-histogram-questions/45365>\
**Category:** Newbie\
**Tags:** hist\
**Created:** [June 11, 2021, 8:56pm UTC](https://root-forum.cern.ch/t/1d-histogram-questions/45365 "2021-06-11T20:56:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![obitter16](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/obitter16/32/26442_2.png) [@obitter16](https://root-forum.cern.ch/u/obitter16)\
**Post date:** [June 11, 2021, 8:56pm UTC](https://root-forum.cern.ch/t/1d-histogram-questions/45365/1 "2021-06-11T20:56:16Z")

</div>

Dear Experts,

I’m new to drawing 1D histograms in ROOT and I’m having trouble finding out how to maintain the same size of the bins on the x-axis.

Also, how would one draw vertical lines separating said bins?

I’d greatly appreciate any help in this matter. Thank you!

_ROOT Version:_ 6.14/04  
Built for macosx64  
From tags/v6-14-04@v6-14-04  
(I use MacBookAir.)

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [June 12, 2021, 8:53am UTC](https://root-forum.cern.ch/t/1d-histogram-questions/45365/2 "2021-06-12T08:53:29Z")

</div>

You control the bin size by [creating the histogram](https://root.cern/doc/master/classTH1.html#a82f16fb9b9a11c97f1c9177e9e996fc7) carefullly, either by giving the appropriate:

- nbins, xlow and xup, or
- nbins and xbins (array)

To see bars on the bins, you can use `SetFillStyle(0)` and draw with the “bar” option:

```auto
   auto c1 = new TCanvas("c1","c1",600,400);
   auto he = new TH1F("he","Histogram",6,-3,3);
   for (int i=0; i<10000; i++) he->Fill(gRandom->Gaus(0,1));
   he->SetMarkerStyle(20);
   he->SetFillStyle(0);
   he->Draw("bar");

```

![c1](https://root-forum.cern.ch/uploads/default/original/3X/5/8/58d3d39c656558c84d04581aad4aa2baac3791e8.png)

---

<div class="post-metadata">

**Author:** ![obitter16](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/obitter16/32/26442_2.png) [@obitter16](https://root-forum.cern.ch/u/obitter16)\
**Post date:** [June 13, 2021, 4:19pm UTC](https://root-forum.cern.ch/t/1d-histogram-questions/45365/3 "2021-06-13T16:19:47Z")

</div>

@dastudillo Thank you, it worked! I do have one quick follow-up though. Is it possible to see the bars on the bins while still filling the histogram with a different color other than white?

I’m asking because I wish to layer multiple 1D histograms and would need to differentiate them by color. Thank you.

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [June 13, 2021, 4:34pm UTC](https://root-forum.cern.ch/t/1d-histogram-questions/45365/4 "2021-06-13T16:34:26Z")

</div>

Check out the bar chart, offset and other drawing options:  
[https://root.cern/doc/master/classTHistPainter.html#HP100](https://root.cern/doc/master/classTHistPainter.html#HP100)
