# Save TMVA plot in png

**URL:** <https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043>\
**Category:** TMVA\
**Created:** [October 14, 2016, 6:45am UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043 "2016-10-14T06:45:10Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [October 14, 2016, 6:45am UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/1 "2016-10-14T06:45:10Z")

</div>

Dear experts,  
I’m using ROOT TMVA and the plots are save in eps. How can I save then in png?  
Regards

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [October 14, 2016, 5:49pm UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/2 "2016-10-14T17:49:25Z")

</div>

Dear experts,  
any idea?  
Regards

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [October 14, 2016, 5:59pm UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/3 "2016-10-14T17:59:21Z")

</div>

Be more explicit. What graph class are you exactly using? Which function do you use for saving the canvas?

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [October 14, 2016, 6:18pm UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/4 "2016-10-14T18:18:45Z")

</div>

Hi ferhue,

I’m using the TMVAClassification function in my own macro. I followed the tutorial TMVAClassification function.

Regards

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [October 14, 2016, 7:38pm UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/5 "2016-10-14T19:38:02Z")

</div>

Do you mean this?  
[root.cern.ch/doc/v606/TMVAClass … ource.html](https://root.cern.ch/doc/v606/TMVAClassification_8C_source.html)

Do you call the function Print or SaveAs at some point by yourself?

Anyway, just take a look at line 234 of:  
[root.cern.ch/doc/v606/tmvaglob\_8cxx\_source.html](https://root.cern.ch/doc/v606/tmvaglob_8cxx_source.html)

I guess that modifying the variable gConfig().fVariablePlotting.fUsePaperStyle would do what you ask for. Or just TMVA::UsePaperStyle if it is an older version.

---

<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:** [October 17, 2016, 7:51am UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/6 "2016-10-17T07:51:37Z")

</div>

The Canvas methods Print or SaveAS can generate many file output formats including png.

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [October 20, 2016, 7:21am UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/7 "2016-10-20T07:21:39Z")

</div>

Dear experts,  
thank you for your answers. May I give you more information on what I’m doing. Indeed, I’m using the code in cc in root version 6. When it finish, I call the “TMVA::TMVAGui(“TMVA.root”)”. After I pushed the button, it creates plots in eps format in a plot directory. Now I want the plots to be in png (or pfd…), do you know how I can configure for that?  
Regards  
[main.cc](https://root-forum.cern.ch/uploads/default/original/2X/8/845255a596f4e3821d1f5dda8df1e8bc03cc3c46.cc) (4.29 KB)

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [October 20, 2016, 9:14am UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/8 "2016-10-20T09:14:12Z")

</div>

Did you try to call this before pushing the button or opening the GUI:

```auto
TMVA::gConfig().fVariablePlotting.fUsePaperStyle=0
```

See line 230 of [root.cern.ch/doc/v606/tmvaglob\_8cxx\_source.html](https://root.cern.ch/doc/v606/tmvaglob_8cxx_source.html)

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [October 20, 2016, 11:36am UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/9 "2016-10-20T11:36:25Z")

</div>

Hi ferhue,

if I run successively [1], then it works, but if I put it in my code, it does not work. The line you mentioned says to modify a code but as this is root TMVA, I do not see how to do that?

Regards

[1]  
$ root -l  
root [0] TMVA::gConfig().fVariablePlotting.fUsePaperStyle=0  
(Bool\_t) false  
root [1] TMVA::TMVAGui(“mt/TMVA.root”)

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [October 20, 2016, 11:58am UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/10 "2016-10-20T11:58:25Z")

</div>

If I understand correctly, your program just generates a file TMVA.root

Then you close ROOT. When you open the exported file with the TMVAGUI, you need to set the fUsePaperStyle variable to 0.

If you do not want to this every time, you can add this line in your rootlogon.C

Otherwise, you can modify the macro tmvaglob.cxx so that it always exports to png no matter the value of fUsePaperStyle. See in the sources /opt/root6\_src/tmva/tmvagui/src/tmvaglob.cxx  
[root.cern.ch/doc/v606/tmvaglob\_8cxx\_source.html](https://root.cern.ch/doc/v606/tmvaglob_8cxx_source.html)

```auto
                  cout << "--- --------------------------------------------------------------------" << endl;
  235 cout << "--- If you want to save the image as eps, gif or png, please comment out " << endl;
  236 cout << "--- the corresponding lines (line no. 239-241) in tmvaglob.C" << endl;
  237 cout << "--- --------------------------------------------------------------------" << endl;
```

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [October 20, 2016, 1:03pm UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/11 "2016-10-20T13:03:29Z")

</div>

Hi ferhue,

ok, and where can I find the file “tmvaglob.cxx”? when I do:  
ls $ROOTSYS/tutorials/tmva/  
I have [1] and “find $ROOTSYS tmvaglob.cxx” says "find: `tmvaglob.cxx’: No such file or directory"  
Am I looking in the right directory?  
Regards

[1]  
-rw-r–r-- 1 cvmfs 1.9K May 31 21:45 tmva\_logo.gif  
-rw-r–r-- 1 cvmfs 242 May 31 21:45 sigmoid-small.png  
-rw-r–r-- 1 cvmfs 1.1K May 31 21:45 makefile  
-rw-r–r-- 1 cvmfs 183 May 31 21:45 line-small.png  
-rw-r–r-- 1 cvmfs 60K May 31 21:45 createData.C  
-rw-r–r-- 1 cvmfs 7.0K May 31 21:45 TMVARegressionApplication.C  
-rw-r–r-- 1 cvmfs 14K May 31 21:45 TMVARegression.C  
-rw-r–r-- 1 cvmfs 17K May 31 21:45 TMVAMultipleBackgroundExample.C  
-rw-r–r-- 1 cvmfs 6.5K May 31 21:45 TMVAMulticlassApplication.C  
-rw-r–r-- 1 cvmfs 6.3K May 31 21:45 TMVAMulticlass.C  
-rw-r–r-- 1 cvmfs 4.0K May 31 21:45 TMVAGAexample2.C  
-rw-r–r-- 1 cvmfs 6.2K May 31 21:45 TMVAGAexample.C  
-rw-r–r-- 1 cvmfs 5.4K May 31 21:45 TMVAClassificationCategoryApplication.C  
-rw-r–r-- 1 cvmfs 7.7K May 31 21:45 TMVAClassificationCategory.C  
-rw-r–r-- 1 cvmfs 21K May 31 21:45 TMVAClassificationApplication.C  
-rw-r–r-- 1 cvmfs 28K May 31 21:45 TMVAClassification.C  
drwxr-xr-x 2 cvmfs 4 Jun 1 10:18 data

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [October 20, 2016, 1:19pm UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/12 "2016-10-20T13:19:25Z")

</div>

In the root sources:  
root\_src/tmva/tmvagui/src/tmvaglob.cxx

I guess you need to change that, and then call “make” again.

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [October 20, 2016, 1:35pm UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/13 "2016-10-20T13:35:20Z")

</div>

The alternative is to edit your rootlogon.C, which does not require to compile again.

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [October 20, 2016, 2:23pm UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/14 "2016-10-20T14:23:48Z")

</div>

Hi ferhue,

in my home I created 2 files:  
~/.rootrc  
Rint.Logon: ~/rootlogon.C  
and  
~/rootlogon.C  
TMVA::gConfig().fVariablePlotting.fUsePaperStyle=0

but when I run root I have the error mesage:  
/…/rootlogon.C:1:16: error: expected function body after function declarator  
TMVA::gConfig().fVariablePlotting.fUsePaperStyle=0  
^  
Do you know what is wrong?  
Regards

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [October 20, 2016, 3:50pm UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/15 "2016-10-20T15:50:35Z")

</div>

`{
	TMVA::gConfig().fVariablePlotting.fUsePaperStyle=0;
}
`

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [October 21, 2016, 6:52am UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/16 "2016-10-21T06:52:19Z")

</div>

Dear ferhue,  
I did that and restart, I do not have error message but I still can’t get the .png file (only .eps).  
Regards

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [October 21, 2016, 8:05am UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/17 "2016-10-21T08:05:37Z")

</div>

Weird.

Can you check the output of this command, after starting ROOT?

```auto
cout << TMVA::gConfig().fVariablePlotting.fUsePaperStyle << endl;
```

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [October 21, 2016, 9:35am UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/18 "2016-10-21T09:35:03Z")

</div>

It works for me, see below:

```auto
ferhue@linuxbox:/opt/root/tutorials/tmva$ root
   ----------------------------------------------------------------
  | Welcome to ROOT 6.09/01 http://root.cern.ch |
  | (c) 1995-2016, The ROOT Team |
  | Built for linuxx8664gcc |
  | From heads/master@v6-09-01-191-g5683cff, Okt 20 2016, 14:31:49 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ----------------------------------------------------------------
root [0] cout << TMVA::gConfig().fVariablePlotting.fUsePaperStyle << endl;
0
root [1] TMVA::TMVAGui()
--- Launch TMVA GUI to view input file: TMVA.root
=== Note: inactive buttons indicate classifiers that were not trained, ===
=== or functionalities that were not invoked during the training ===
root [2] --- Opening root file TMVA.root in read mode
--- --------------------------------------------------------------------
--- If you want to save the image as eps, gif or png, please comment out 
--- the corresponding lines (line no. 239-241) in tmvaglob.C
--- --------------------------------------------------------------------
Info in <TCanvas::Print>: eps file dataset/plots/variables_id_c1.eps has been created
Info in <TCanvas::Print>: file dataset/plots/variables_id_c1.png has been created
root [2] .q
```

---

<div class="post-metadata">

**Author:** ![calbet](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/c/4af34b/32.png) [@calbet](https://root-forum.cern.ch/u/calbet)\
**Post date:** [October 21, 2016, 11:19am UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/19 "2016-10-21T11:19:24Z")

</div>

Hi ferhue,

I have in root 6.06/01:

[…]$ root -l  
root [0] cout \<\< TMVA::gConfig().fVariablePlotting.fUsePaperStyle \<\< endl;  
0  
root [1] TMVA::TMVAGui(“mt/TMVA.root”)  
— Launch TMVA GUI to view input file: mt/TMVA.root  
=== Note: inactive buttons indicate classifiers that were not trained, ===  
=== or functionalities that were not invoked during the training ===  
root [2] — Opening root file mt/TMVA.root in read mode  
— Found directory for method: BDT::BDTD containing MVA\_BDTD\_S/\_B  
— Mean and RMS (S): 0.142985, 0.163495  
— Mean and RMS (B): -0.220557, 0.276945  
Info in TCanvas::Print: eps file plots/mva\_BDTD.eps has been created  
[…]$

---

<div class="post-metadata">

**Author:** ![ferhue](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ferhue/32/29462_2.png) [@ferhue](https://root-forum.cern.ch/u/ferhue)\
**Post date:** [October 21, 2016, 12:06pm UTC](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043/20 "2016-10-21T12:06:11Z")

</div>

Hmmm, maybe it is because of the ROOT version, but not sure…

Try instead:

```auto
{
	TMVAGlob::UsePaperStyle=0;
	//or TMVA::TMVAGlob::UsePaperStyle=0;
}
```

[Next page](https://root-forum.cern.ch/t/save-tmva-plot-in-png/22043.md?page=2)
