# How to draw histogram of 2D array by TTree::Draw()

**URL:** <https://root-forum.cern.ch/t/how-to-draw-histogram-of-2d-array-by-ttree-draw/64335>\
**Category:** Newbie\
**Created:** [October 18, 2025, 12:21pm UTC](https://root-forum.cern.ch/t/how-to-draw-histogram-of-2d-array-by-ttree-draw/64335 "2025-10-18T12:21:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Crisps](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/crisps/32/39101_2.png) [@Crisps](https://root-forum.cern.ch/u/Crisps)\
**Post date:** [October 18, 2025, 12:21pm UTC](https://root-forum.cern.ch/t/how-to-draw-histogram-of-2d-array-by-ttree-draw/64335/1 "2025-10-18T12:21:05Z")

</div>

* * *

_Dear experts_

How can I draw the 2D histogram of a 2D array a[m][n], where the x axis is m and y axis is a (value)?

For example if I have a[300][20] I should have a 2D histogram where x axis range is 0 ~ 299.

I know I can write a simple for loop to do this, I just want to know if TTree::Draw() can do it in just one line code.

* * *

---

<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:** [October 19, 2025, 10:00am UTC](https://root-forum.cern.ch/t/how-to-draw-histogram-of-2d-array-by-ttree-draw/64335/3 "2025-10-19T10:00:00Z")

</div>

Deleted my previous post as I had skipped the fact that you are reading a 2D array from the tree. I don’t think TTree::Draw() can do what you want (except perhaps with some wizardry 🙂 ). There may be a way with RDataFrame, but I’ll leave that to an expert.
