# 2D Histograms directly from two branches in the rootfile

**URL:** <https://root-forum.cern.ch/t/2d-histograms-directly-from-two-branches-in-the-rootfile/34592>\
**Category:** Newbie\
**Created:** [June 14, 2019, 4:25am UTC](https://root-forum.cern.ch/t/2d-histograms-directly-from-two-branches-in-the-rootfile/34592 "2019-06-14T04:25:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sanjeeda](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sanjeeda/32/37613_2.png) [@sanjeeda](https://root-forum.cern.ch/u/sanjeeda)\
**Post date:** [June 14, 2019, 4:25am UTC](https://root-forum.cern.ch/t/2d-histograms-directly-from-two-branches-in-the-rootfile/34592/1 "2019-06-14T04:25:14Z")

</div>

I have two trees in my root file, named **ncandidates** and **events**. How do I plot a histogram with **ncandidates** on the x axis and **events** on the y axis by writing a command directly on the terminal instead of the ROOT macro?

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [June 14, 2019, 6:26am UTC](https://root-forum.cern.ch/t/2d-histograms-directly-from-two-branches-in-the-rootfile/34592/2 "2019-06-14T06:26:36Z")

</div>

Search for “friend” and “alias” in the [TTree](https://root.cern.ch/doc/master/classTTree.html) class reference.

See also: [ROOT User’s Guide -\> Trees -\> Example 3: Adding Friends to Trees](https://root.cern.ch/root/htmldoc/guides/users-guide/ROOTUsersGuide.html#example-3-adding-friends-to-trees)
