Converting histograms stored in root files to .png's

I have written TH1F histograms to a root file within a script (TFile *f = new Tfile(“check.root”, “recreate”)) and I am trying to find a way to not go through each histogram in the root file and “save” it. Is there a way to export these root files either within the script or another script and save it as a .png? I did not draw these histograms to a TCanvas in my script, and I am trying to avoid doing so which is why I wrote it to a root file in the first place. I understand that .root files are not graphical, but is there still a way? Any help or suggestion will be much appreciated!

If you use ROOT 6, try:
ls `root-config --bindir`/root*
rootprint --help

4 Likes

and if you’re on Windows (so, stuck w/ ROOT-5):

you can also use:

:slight_smile:

(it also works for Linux, macOS, *BSDs, …)

1 Like

I am using root 6.6.08… this is what happens when I try to use this “rootprint”:

Traceback (most recent call last):
  File "/usr/local/root/bin/rootprint", line 10, in <module>
    import cmdLineUtils
ImportError: No module named cmdLineUtils

and I’m on a mac OS x… note that this error also happens via root 5 (using root-print)

If you’re on CSH, Try:

setenv PYTHONPATH $ROOTSYS/lib:${PYTHONPATH}

EDIT: Shell Corrected

1 Like

are you sure you are using “my” root-print command?

that can’t be the case as go-hep/rootio doesn’t use python.

if on bash, that should read:

$> export PYTHONPATH=$ROOTSYS/lib:$PYTHONPATH

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.