# Help with Plotting multiple histograms stored in a vector

**URL:** <https://root-forum.cern.ch/t/help-with-plotting-multiple-histograms-stored-in-a-vector/56571>\
**Category:** Newbie\
**Created:** [October 2, 2023, 10:29am UTC](https://root-forum.cern.ch/t/help-with-plotting-multiple-histograms-stored-in-a-vector/56571 "2023-10-02T10:29:02Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Natilus](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/7cd45c/32.png) [@Natilus](https://root-forum.cern.ch/u/Natilus)\
**Post date:** [October 2, 2023, 10:29am UTC](https://root-forum.cern.ch/t/help-with-plotting-multiple-histograms-stored-in-a-vector/56571/1 "2023-10-02T10:29:02Z")

</div>

Dear Root experts,  
I have a quite interesting problem and don’t know how to approach it.  
I create a vector of TH1D\* and fill the histogram with data.  
I would like to plot them on the same canvas with different colors in order to compare.

When plotting I only see colorful crosses in the plot and not filled histograms.

I noticed if I define/declare and fill the histograms separately (not making vector of TH1D\*), everything will be plotted fine. I will have histograms with histograms filled and with different colors.

So I know the problem is storing the histograms in a vector. But I need to do so since the number of histograms is large and working with separate histograms (compared to a vector if THD1\*) makes the code extremely long.

Here is my code (part of it) an example when I use a vector:  
[BVertexProbability.cc](https://root-forum.cern.ch/uploads/short-url/t1vw9CZ2jez5L0GieIOYrDQBhbj.cc) (6.9 KB)

 ![BVtxProb](https://root-forum.cern.ch/uploads/default/original/3X/3/8/385edfee5d5f94cea173ba0668b667d4c66758d8.png)

Thank you for the help

---

<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:** [October 2, 2023, 12:27pm UTC](https://root-forum.cern.ch/t/help-with-plotting-multiple-histograms-stored-in-a-vector/56571/2 "2023-10-02T12:27:00Z")

</div>

use option `HIST` when you draw the histograms.

---

<div class="post-metadata">

**Author:** ![Natilus](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/n/7cd45c/32.png) [@Natilus](https://root-forum.cern.ch/u/Natilus)\
**Post date:** [October 2, 2023, 1:38pm UTC](https://root-forum.cern.ch/t/help-with-plotting-multiple-histograms-stored-in-a-vector/56571/3 "2023-10-02T13:38:59Z")

</div>

Hi @couet ,  
Thank you very much. That worked beautifully.
