# How to create a histogam from a .dat file

**URL:** <https://root-forum.cern.ch/t/how-to-create-a-histogam-from-a-dat-file/35286>\
**Category:** Newbie\
**Created:** [July 20, 2019, 11:03pm UTC](https://root-forum.cern.ch/t/how-to-create-a-histogam-from-a-dat-file/35286 "2019-07-20T23:03:49Z")\
**Posts on this page:** 1\
**Showing post:** 3

<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:** [July 21, 2019, 11:07am UTC](https://root-forum.cern.ch/t/how-to-create-a-histogam-from-a-dat-file/35286/3 "2019-07-21T11:07:13Z")

</div>

> [@Filling Histograms with a text file](https://root-forum.cern.ch/t/filling-histograms-with-a-text-file/34190/2):
>
> Try: /\* Usage examples: root [0] .L Am241.cxx root [1] Am241(); // expects "Am241.txt" in the current directory root [1] Am241("/full/path/to/some/Am241.txt"); or simply: root [0] .x Am241.cxx root [0] .x Am241.cxx("/full/path/to/some/Am241.txt") \*/ #include "TGraph.h" #include \<fstream\> void Am241(const char \*file = "Am241.txt") { if ((!file) || (!file[0])) return; // just a precaution TGraph \*g = new TGraph(); g-\>SetTitle("Count Rate;N\_{counts};# occurencies"); double y;…

---

_[View the full topic](https://root-forum.cern.ch/t/how-to-create-a-histogam-from-a-dat-file/35286)._
