# How to convert root graphs into .dat format?

**URL:** <https://root-forum.cern.ch/t/how-to-convert-root-graphs-into-dat-format/32184>\
**Category:** Newbie\
**Created:** [January 7, 2019, 10:23am UTC](https://root-forum.cern.ch/t/how-to-convert-root-graphs-into-dat-format/32184 "2019-01-07T10:23:32Z")\
**Posts on this page:** 1\
**Showing post:** 9

<div class="post-metadata">

**Author:** ![sbinet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/sbinet/32/13166_2.png) [@sbinet](https://root-forum.cern.ch/u/sbinet)\
**Post date:** [January 8, 2019, 8:39am UTC](https://root-forum.cern.ch/t/how-to-convert-root-graphs-into-dat-format/32184/9 "2019-01-08T08:39:03Z")

</div>

note that a histogram is much more than just points on a 2D plane.  
it carries a bunch of statistical informations.

one can use [root-dump](https://godoc.org/go-hep.org/x/hep/groot/cmd/root-dump) to print – in ASCII art – the content of histograms (1D and 2D):

```auto
$> root-ls gauss-h1.root 
=== [gauss-h1.root] ===
version: 60806
TH1D h1d h1d (cycle=1)
TH1F h1f h1f (cycle=1)
TH1F h1d-var h1d-var (cycle=1)
TH1F h1f-var h1f-var (cycle=1)

$> root-dump -name=h1d-var gauss-h1.root
>>> file[gauss-h1.root]
key[000]: h1d;1 "h1d" (TH1D)
key[001]: h1f;1 "h1f" (TH1F)
key[002]: h1d-var;1 "h1d-var" (TH1F)
BEGIN YODA_HISTO1D /h1d-var
Path=/h1d-var
Title=h1d-var
Type=Histo1D
# Mean: 2.812016e-02
# Area: 1.100600e+04
# ID ID sumw sumw2 sumwx sumwx2 numEntries
Total Total 1.100600e+04	1.211000e+04	3.094905e+02	7.128989e+04	10004
Underflow	Underflow	2.000000e+00	2.000000e+00	0.000000e+00	0.000000e+00	2
Overflow	Overflow	4.000000e+00	8.000000e+00	0.000000e+00	0.000000e+00	2
# xlow xhigh sumw sumw2 sumwx sumwx2 numEntries
-4.000000e+00	-3.200000e+00	6.600000e+00	7.260000e+00	0.000000e+00	0.000000e+00	6
-3.200000e+00	-2.400000e+00	7.259995e+01	7.986000e+01	0.000000e+00	0.000000e+00	66
-2.400000e+00	-1.600000e+00	5.434013e+02	5.977400e+02	0.000000e+00	0.000000e+00	494
-1.600000e+00	-8.000000e-01	1.708276e+03	1.879130e+03	0.000000e+00	0.000000e+00	1553
-8.000000e-01	0.000000e+00	3.130664e+03	3.443660e+03	0.000000e+00	0.000000e+00	2846
0.000000e+00	8.000000e-01	3.136165e+03	3.449710e+03	0.000000e+00	0.000000e+00	2851
8.000000e-01	1.600000e+00	1.753375e+03	1.928740e+03	0.000000e+00	0.000000e+00	1594
1.600000e+00	2.400000e+00	5.401014e+02	5.941100e+02	0.000000e+00	0.000000e+00	491
2.400000e+00	3.200000e+00	1.011999e+02	1.113200e+02	0.000000e+00	0.000000e+00	92
3.200000e+00	4.000000e+00	7.700000e+00	8.470000e+00	0.000000e+00	0.000000e+00	7
END YODA_HISTO1D

key[003]: h1f-var;1 "h1f-var" (TH1F)

```

`root-dump` converts `TH{1,2}x` histograms to [YODA](https://yoda.hepforge.org/) histograms.

That said, it seems you want to extract that data to plot it with another plotting system.  
Which one is it? There is perhaps a less convoluted way to do that…

hth,  
-s

---

_[View the full topic](https://root-forum.cern.ch/t/how-to-convert-root-graphs-into-dat-format/32184)._
