# Plotting Histogram from Two Column of Data

**URL:** <https://root-forum.cern.ch/t/plotting-histogram-from-two-column-of-data/45453>\
**Category:** Newbie\
**Created:** [June 17, 2021, 7:56pm UTC](https://root-forum.cern.ch/t/plotting-histogram-from-two-column-of-data/45453 "2021-06-17T19:56:04Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheScientist](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/82dd89/32.png) [@TheScientist](https://root-forum.cern.ch/u/TheScientist)\
**Post date:** [June 17, 2021, 7:56pm UTC](https://root-forum.cern.ch/t/plotting-histogram-from-two-column-of-data/45453/1 "2021-06-17T19:56:04Z")

</div>

I have two column of data - Energy (x-axis) and Flux (y-axis) - in a txt file. I am trying to plot the histogram but I am having trouble in filling up a data. Please let me know the error in my code and how to deal with it. Thank you/

```auto
{
TNtuple t("Flux_data", "Data from DUNE", "Energy:Flux");
t.ReadFile("data.txt");

// manually created histogram
TH1F h("Flux_Hist","Energy vs. Flux", 100, 0, 40);
h.Fill("Energy");
h.Fill("Flux")
h.Draw();
}

```

---

<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:** [June 18, 2021, 8:51am UTC](https://root-forum.cern.ch/t/plotting-histogram-from-two-column-of-data/45453/2 "2021-06-18T08:51:58Z")

</div>

```auto
{
   auto t = new TNtuple("Flux_data", "Data from DUNE", "Energy:Flux");
   t->ReadFile("data.txt");
   t->Draw("Energy:Flux");
}

```

---

<div class="post-metadata">

**Author:** ![TheScientist](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/t/82dd89/32.png) [@TheScientist](https://root-forum.cern.ch/u/TheScientist)\
**Post date:** [June 24, 2021, 12:25am UTC](https://root-forum.cern.ch/t/plotting-histogram-from-two-column-of-data/45453/3 "2021-06-24T00:25:31Z")

</div>

This one does not work. It only gives me scatterplot.

---

<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:** [June 24, 2021, 6:41am UTC](https://root-forum.cern.ch/t/plotting-histogram-from-two-column-of-data/45453/4 "2021-06-24T06:41:58Z")

</div>

> [@TheScientist](#):
>
> It only gives me scatterplot.

What do you want ?
