# How to create TGraph2D for correlation between two branches of a TTree

**URL:** <https://root-forum.cern.ch/t/how-to-create-tgraph2d-for-correlation-between-two-branches-of-a-ttree/46672>\
**Category:** Newbie\
**Created:** [September 4, 2021, 8:48am UTC](https://root-forum.cern.ch/t/how-to-create-tgraph2d-for-correlation-between-two-branches-of-a-ttree/46672 "2021-09-04T08:48:49Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![paulan](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@paulan](https://root-forum.cern.ch/u/paulan)\
**Post date:** [September 4, 2021, 8:48am UTC](https://root-forum.cern.ch/t/how-to-create-tgraph2d-for-correlation-between-two-branches-of-a-ttree/46672/1 "2021-09-04T08:48:50Z")

</div>

Hi, I am new to ROOT! I have a correlation plot of two branches from a TTree which I produced using

```auto
tree->Draw("x:y", cuts applied)

```

but now I would like to obtain a colored plot based on the intensity of points. I understand that TGraph2D has drawing options like PCOL, but I don’t know how could I create TGraph2D from TTree. Any help would be appreciated, thanks!

\_ROOT Version: 6.24/02

---

<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:** [September 4, 2021, 11:22am UTC](https://root-forum.cern.ch/t/how-to-create-tgraph2d-for-correlation-between-two-branches-of-a-ttree/46672/2 "2021-09-04T11:22:36Z")

</div>

```auto
tree->Draw("x:y", cuts applied,"colz");

```

---

<div class="post-metadata">

**Author:** ![paulan](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/p/b77776/32.png) [@paulan](https://root-forum.cern.ch/u/paulan)\
**Post date:** [September 7, 2021, 3:31pm UTC](https://root-forum.cern.ch/t/how-to-create-tgraph2d-for-correlation-between-two-branches-of-a-ttree/46672/3 "2021-09-07T15:31:35Z")

</div>

Thank you! This worked.
