# TH2D working like a TGraph

**URL:** <https://root-forum.cern.ch/t/th2d-working-like-a-tgraph/58280>\
**Category:** Newbie\
**Tags:** hist, root\
**Created:** [February 24, 2024, 9:25am UTC](https://root-forum.cern.ch/t/th2d-working-like-a-tgraph/58280 "2024-02-24T09:25:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrea\_Frassa1](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/andrea_frassa1/32/34642_2.png) [@Andrea\_Frassa1](https://root-forum.cern.ch/u/Andrea_Frassa1)\
**Post date:** [February 24, 2024, 9:25am UTC](https://root-forum.cern.ch/t/th2d-working-like-a-tgraph/58280/1 "2024-02-24T09:25:29Z")

</div>

Hi,  
I have a problem, _maybe a silly one_, with TH2D.  
In this macro I just need a simple TH2D filled with points previously calculated.

TCanvas\* t3 = new TCanvas();  
t3-\>SetCanvasSize(1500, 1500);  
t3-\>SetWindowSize(1500, 1500);  
t3-\>cd();  
TH2D\* h1 = new TH2D(“HeatMap”, “Hit Map”, 10, 19.5, 21.5, 10, -1.3, 1.3);  
h1-\>SetTitle(“GPD input”);  
h1-\>GetXaxis()-\>SetTitle(“X [cm]”);  
h1-\>GetYaxis()-\>SetTitle(“Y [cm]”);  
for(int i = 0; i\<count; i++){  
h1-\>Fill(xhit[i], yhit[i]);  
}  
h1-\>Draw();  
Note that this does not improve using less bins.  
The issue is that the output shows a TGraph like plot with dots instead of binned data.

 ![Screenshot from 2024-02-24 10-19-58](https://root-forum.cern.ch/uploads/default/original/3X/4/1/417950c82b67cf96a9a7ecca28aa8df547f6b213.png)  
Can you help me with this small problem?

\_ROOT Version: 6.26/10  
\_Platform: Ubuntu  
\_Compiler: GLIBCXX

* * *

---

<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:** [February 24, 2024, 9:34am UTC](https://root-forum.cern.ch/t/th2d-working-like-a-tgraph/58280/2 "2024-02-24T09:34:58Z")

</div>

Hello Andrea,

Thanks for the post and welcome to the ROOT community!  
Forgive me if I misunderstand, but are you looking for the [drawing options for 2D histograms](https://root.cern/doc/master/classTHistPainter.html#HP01a) perhaps?  
If not, please do not hesitate to come back with more questions!

Cheers,  
Danilo

---

<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 26, 2024, 12:08pm UTC](https://root-forum.cern.ch/t/th2d-working-like-a-tgraph/58280/3 "2024-02-26T12:08:47Z")

</div>

The option “SCAT” was the default one for TH2D until recently. It was misleading. It is now deprecated. The default option is now “COL”. Of course TH2D are binned data. If you need a real scatter plot (not binned) use [TScatter](https://root.cern.ch/blog/new-class-tscatter/)…
