GAMS to Gnuplot/Shademap to PowerPoint

Uwe A. Schneider, Delf Neubersch, Ingo Huck

Last modified June 2014

GAMS Syntax
Automatic PowerPoint Import
Macro based PowerPoint Import

Other GAMS interfaces  from/to:  ShadeMap   Gnuplot   Stata    Powerpoint    Html    Awk



Description  (back to top)

The tools available here allow users to put gnuplot figures and shademap plot obtained from GAMS runs into powerpoint. Please report bugs, improvements, or other comments to uwe.schneider{at} 

Download  (back to top)

GAMS to Gnuplot: Gnuplotxyz

GAMS to ShadeMap

Option 1: Phyton based program to automatically make ppt slides (Contributed by Delf Neubersch). To use this option, save the following two files in the .\inclib subdirectory of your gams system directory: compileppt.exe, default.pptx

Option 2: Powerpoint file  with Macro for loading and emptying gnuplot figures and shaded maps (Contributed by Ingo Huck)

Gams Syntax  (back to top)

for Gnuplot:       $setglobal gp_ppt yes

for Shademap:   $setglobal sm_ppt yes

The above command inside your GAMS program saves all graphs produced by $libinclude gnuplotxyz .../$libinclude shademap ...  as picture files in your working directory with automatically different file names. In addition, all file names and file locations will be written into a text file. These text files are named gams_ppt_list.txt and reside in the /inclib subdirectory of your gams system.

By gnuplot default and always for shademap, the picture format will be the memory sparing EMF.  If you want other formats for gnuplot figures (i.e. GIF), you have to use the following statements in addition to the one above. Note that other formats have not been tested and may produce errors. 

$setglobal gp_term <terminal name>

Slide titles

The title of the plot will be put as text box on each slide. The following text format modifiers can be used to determine the appearance of the slide title:

$setglobal gp_ppt_fontname     "Times New Roman"
$setglobal gp_ppt_fontsize        25
$setglobal gp_ppt_boldfont       yes

The content of the title is determined through gp_title [and gp_loop1, ...,  gp_loop4 if loops are involved] as described on the  Gnuplot interface pages.

The option gp_ppt_boldfont only works with the powerpoint macro.

Multiple execution of the same plot file

Occasionally, one runs the same plot producing file on different data sets in order to compare specific plots across different runs. If one uses only the $setglobal gp_ppt yes option, he/she could sequentially insert the entire figures produced by each run in one ppt file. However, this order would make a comparison difficult. To ease comparison across runs, one may want to order the slides in a specific way, where each slide is repeated for all runs before showing the next slide. To achieve such an order, the follwoing additional syntax must be used:

$setglobal gp_ppt_a   b

where a and b have to be numbers between 1 and 9. a identifies how many comparison runs you have (Note that 2,3,4,6, and 9 runs go well with the print handout option in MS PowerPoint). b identifies the current run. For example, one could have the four following statements for four comparison runs, which should be executed one after another.

First run (perhaps using restart file a1)

$setglobal gp_ppt_4    1
*$setglobal gp_ppt_4    2
*$setglobal gp_ppt_4    3
*$setglobal gp_ppt_4    4

Last run (perhaps using restart file a4)

*$setglobal gp_ppt_4    1
*$setglobal gp_ppt_4    2
*$setglobal gp_ppt_4    3
$setglobal gp_ppt_4    4

The title of each comparison run can be added to the existing plot title of the slide by using

$setglobal gp_ppt_1_name  " for population growth"
$setglobal gp_ppt_2_name  " for biodiversity decline"
$setglobal gp_ppt_3_name  " for climate change"
$setglobal gp_ppt_4_name  " for mars people landing


1) Automatic PowerPoint Import   (back to top)

The default name of the powerpoint file is gams_slides.pptx and will be created in the project directory.

One can override the default name (and path) by specifying the option ppt_filename

$setglobal ppt_filename <path>myslides.pptx

At the end of the file which produce gnuplot or shademap files, place the following statement:

$libinclude gnuplotxyz compileppt


2) Manual PowerPoint Import with Macros   (back to top)

To import the pictures from your GAMS run into POWERPOINT, open the Powerpoint file  

Enabling Macro Execution

The power point interface uses a small macro compiled in Visual Basics. To use it, you have to enable macros.

The dialogs differ for different languages and between Office 2003 and earlier and Office 2007 and later.

In MS Office 2007 (and later), opening a ppt which contains the macro for ppt import will show the following option bar:

click on Options ...

Choose "Enable this content" and click "OK".

The go to to the VIEW tab, click on MACROS, select EnterPictures, and click Run.

Now you are ready to use the picture adding macro.


In MS Office 2003, if you get the following dialog

click on "Enable Macro". If you don't get the dialog, your security settings are either too strong or too weak.

You can check your settings by going to "Tools" -- "Options" -- "Security" -- "Macro Security". Medium or lower security is required to run macros.

If macros are enabled, you are ready to use them. Go to "Tools"  -- "Macro" -- "Macros.."

and run the "EnterPictures"



Using the Picture adding Macro

This gives you the following dialog:

Please check that the file path corresponds to your gams system. You can change and save it through the "Save Filepath and name" button.

Gnuplot figures and shaded maps can be loaded simultaneously 

You can click on Insert Pictures to load all gnuplot or shademap pictures of your gams run in power point or you can delete are slides in your power point file.


a) Examine that the specified file path corresponds to the path to your active gams system

b) Check that all picture files which are specified in the file gams_ppt_list.txt exist and can be viewed. Picture files listed with 0KB may be empty files which will not work.


Examples (back to top)

1 Combined gnuplot and shademap figures from single run


Note: You must install shademap and gnuplotxyz and extract these files in the gislib subdirectory of your GAMS system directory!

2 Multiple gnuplot figures for 4 comparison runs

Run example_multi_ppt_plot.gms four times and activate each time the corresponding $setglobal gp_ppt_4 statement.

Open the ppt template and execute the contained macro. The slides should look as in this file web_multirestart.ppt

Print slides using handout options with 4 handouts per page (multirun_slides.pdf)