# Plotting histograms using stars, pointer heads as the plot points

**URL:** <https://root-forum.cern.ch/t/plotting-histograms-using-stars-pointer-heads-as-the-plot-points/34773>\
**Category:** Newbie\
**Created:** [June 23, 2019, 6:50am UTC](https://root-forum.cern.ch/t/plotting-histograms-using-stars-pointer-heads-as-the-plot-points/34773 "2019-06-23T06:50:58Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Angey](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@Angey](https://root-forum.cern.ch/u/Angey)\
**Post date:** [June 23, 2019, 6:50am UTC](https://root-forum.cern.ch/t/plotting-histograms-using-stars-pointer-heads-as-the-plot-points/34773/1 "2019-06-23T06:50:58Z")

</div>

Hi. I am completely new to ROOT. It is just a couple of weeks I have started off with it learning to plot histograms for my project however I don’t know how to plot the histograms with the coordinate points marked as stars, pointer heads, etc with different colors as I saw in one of the thesis (whose screenshot I am attaching here) . Kindly reply asap as it would be of a great help to me. ![Screenshot%20from%202019-06-23%2012-05-34](https://root-forum.cern.ch/uploads/default/original/3X/c/6/c6d29f1edb686d3d58e14199aec290acd2663624.png)

---

<div class="post-metadata">

**Author:** ![Dilicus](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dilicus/32/14338_2.png) [@Dilicus](https://root-forum.cern.ch/u/Dilicus)\
**Post date:** [June 23, 2019, 8:31am UTC](https://root-forum.cern.ch/t/plotting-histograms-using-stars-pointer-heads-as-the-plot-points/34773/2 "2019-06-23T08:31:35Z")

</div>

Hi,  
have a look to [THistPainter](https://root.cern/doc/master/classTHistPainter.html) for the marker style and color.  
Than before drawing you have just do

```auto
Hist->SetMarkerStyle(your_style)
Hist->SetMarkerColor(your_color)

```

Cheers  
Stefano

---

<div class="post-metadata">

**Author:** ![Angey](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@Angey](https://root-forum.cern.ch/u/Angey)\
**Post date:** [June 23, 2019, 4:25pm UTC](https://root-forum.cern.ch/t/plotting-histograms-using-stars-pointer-heads-as-the-plot-points/34773/3 "2019-06-23T16:25:13Z")

</div>

Thank you. So, is this only possible to be drawn on a canvas and not as a histogram plot in TBrowser?  
And moreover how do I plot both the plots of u and c quarks as shown in the figure above together in a single plot?  
Is it by using the Add Hist option?

---

<div class="post-metadata">

**Author:** ![Angey](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@Angey](https://root-forum.cern.ch/u/Angey)\
**Post date:** [June 23, 2019, 4:51pm UTC](https://root-forum.cern.ch/t/plotting-histograms-using-stars-pointer-heads-as-the-plot-points/34773/4 "2019-06-23T16:51:20Z")

</div>

In the user’s guide, it is mentioned about the ROOT 6 version but I am using version 5.34/38…So, will it work ?

---

<div class="post-metadata">

**Author:** ![Dilicus](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dilicus/32/14338_2.png) [@Dilicus](https://root-forum.cern.ch/u/Dilicus)\
**Post date:** [June 23, 2019, 4:59pm UTC](https://root-forum.cern.ch/t/plotting-histograms-using-stars-pointer-heads-as-the-plot-points/34773/5 "2019-06-23T16:59:59Z")

</div>

To draw in the same plot you just need to do,

```auto
hist1->Draw();
hist2->Draw("same");

```

From TBrowser you can

- right clic the histogram, open the draw panel and change the marker style and color from there;
- click on view on the top sidebar, click on editor. Then you on the left you will have another tab with called pad editor, clicking on the histogram and then on the pad you can change the styles.

Drawing on the same canvas from TBrowser is possible you just need to write same in the Draw option in the files panel on the top before clicking on your second histogram.

THistPainter should work in root 5.34/38

I highlighted this things in the image attached ![09](https://root-forum.cern.ch/uploads/default/original/3X/c/a/ca4997d6718b31fa3bedc5971ce31c52412da1ed.png)

---

<div class="post-metadata">

**Author:** ![Angey](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@Angey](https://root-forum.cern.ch/u/Angey)\
**Post date:** [June 23, 2019, 5:04pm UTC](https://root-forum.cern.ch/t/plotting-histograms-using-stars-pointer-heads-as-the-plot-points/34773/6 "2019-06-23T17:04:25Z")

</div>

Thank You so much! 🙂

---

<div class="post-metadata">

**Author:** ![Angey](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@Angey](https://root-forum.cern.ch/u/Angey)\
**Post date:** [June 24, 2019, 11:37am UTC](https://root-forum.cern.ch/t/plotting-histograms-using-stars-pointer-heads-as-the-plot-points/34773/7 "2019-06-24T11:37:09Z")

</div>

HI…I tried using the SetMarker and “Same” options and tried reading 4 histograms from a root file (histogram plots namely the pT plots of pion, kaon, proton and d-meson from a root file). However, I am not getting the desired plots. Although I tried reading 4 different histograms, only two histograms seemed to be getting plotted (pdf attached below). I don’t know where I made the mistake. Could you please help? I am also attaching below the macro where I wrote the codes for reading those histogram plots.[unnamed.pdf](https://root-forum.cern.ch/uploads/default/original/3X/3/2/32a73c3dd2229ed74682a47c7408735611adee54.pdf) (16.8 KB)

[Read.C](https://root-forum.cern.ch/uploads/default/original/3X/e/7/e771fade1c335ccae89e77a8b8114d7bdf9a5739.C) (1.4 KB)

---

<div class="post-metadata">

**Author:** ![Dilicus](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dilicus/32/14338_2.png) [@Dilicus](https://root-forum.cern.ch/u/Dilicus)\
**Post date:** [June 24, 2019, 1:53pm UTC](https://root-forum.cern.ch/t/plotting-histograms-using-stars-pointer-heads-as-the-plot-points/34773/8 "2019-06-24T13:53:51Z")

</div>

hi,  
after the `TH1F *hist3=(TH1F*)f->Get("prhpt");` and  
`TH1F *hist4=(TH1F*)f->Get("d0hpt");`  
you always changed the styles of hist2 and not of hist3 or hist4.

If you still not see the other two histograms the y-axis range can be the problem

---

<div class="post-metadata">

**Author:** ![Angey](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@Angey](https://root-forum.cern.ch/u/Angey)\
**Post date:** [June 25, 2019, 4:40am UTC](https://root-forum.cern.ch/t/plotting-histograms-using-stars-pointer-heads-as-the-plot-points/34773/9 "2019-06-25T04:40:42Z")

</div>

Hi… Thank you for pointing out the error in my code. It’s working now after I changed the styles of other two histograms. However, the only issue right now is there are long blue lines appearing along with the marker points…Are those the error bars?? If so, then how do I get to remove them? I have attached below the image of my current plot.[unnamed2.pdf](https://root-forum.cern.ch/uploads/default/original/3X/4/6/4625e2b2043408e6b088538747df483c2ca4c7f7.pdf) (30.0 KB)

---

<div class="post-metadata">

**Author:** ![Dilicus](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dilicus/32/14338_2.png) [@Dilicus](https://root-forum.cern.ch/u/Dilicus)\
**Post date:** [June 25, 2019, 5:14am UTC](https://root-forum.cern.ch/t/plotting-histograms-using-stars-pointer-heads-as-the-plot-points/34773/10 "2019-06-25T05:14:22Z")

</div>

Try this

```auto
hist1->Draw("p hist")
hist2->Draw("p hist same")
hist3->Draw("p hist same")
hist4->Draw("p hist same")

```

S

---

<div class="post-metadata">

**Author:** ![Angey](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/f04885/32.png) [@Angey](https://root-forum.cern.ch/u/Angey)\
**Post date:** [June 26, 2019, 5:04am UTC](https://root-forum.cern.ch/t/plotting-histograms-using-stars-pointer-heads-as-the-plot-points/34773/11 "2019-06-26T05:04:00Z")

</div>

Hi Dilicus…Thanks a lot for the help. It worked! 🙂
