GNUPLOTXYZ.GMS - A Windows based GAMS Interface to GNUPLOT 4.2
Uwe A. Schneider
March 29, 2007
Credits
Description
Download
Installation
2D
Syntax
3D
Syntax
Examples
Options
Modification
Other GAMS interfaces from/to: ShadeMap Gnuplot Stata Powerpoint
This software interface was largely developed by Uwe Schneider. Credit goes to Bruce McCarl who initiated the project and did some initial programming and to Thomas Rutherford . Tom's existing gnuplot interface provided useful guidance. Additional contributions were made by Michael Bussieck and Armin Pruessner from GAMS Development Corporation. Thanks also to Hans-Bernhard Broeker from the GNUPLOT team.
This interface is provided free of charge. There is (almost) no technical support. Bug reports/fixes are welcome. Thanks go to Petr Havlik for useful feedback.
Gnuplotxyz.gms allows users to plot data from GAMS runs in GNUPLOT . Currently the interface only works only with windows. It is somewhat similar to the GNUPLOT interface created by Thomas Rutherford .
Gnuplotxyz.gms is user friendly as only one single line is needed to produce a good plot. Nevertheless, many of the default options can be changed by using optional statements as illustrated below. In addition, one can modify the gnuplotxyz.gms file for personal needs and preferences.
gnuplotxyz.zip contains all files needed for the interface to work
gnuplotxyz.gms contains the most recent version of this file. Whenever I make changes to this file, I will upload it. Updating the archive takes more time and I will not do it frequently.
Simply extract the files contained in the archive gnuplotxyz.zip to your GAMS system directory. Make sure that the files "gnuplotxyz.gms", "callgplt.bat", and "rt1.exe" are extracted to the "/inclib" sub directory of the GAMS system directory.
The data to be graphed as 2D-plot must be contained in a three dimensional parameter (a parameter which has three sets/indexes/dimensions). The number of elements in the first argument determines the number of different lines in a plot. The number of elements in the second argument determines the number of points on a particular line. The order of elements in the second index determines how the different data points pertaining to one line are connected. The remaining argument (third index) must contain at least two set elements of which one represents the x-axis and a second the y-axis coordinates. If you choose styles with error bars you may need to give additional values (see examples).
minimum
$libinclude gnuplotxyz < parameter name>
<xaxis element> <yaxis element>
multiple plots in sequence with custom formatting
[$setglobal < global variable
name> < value>]
[$setglobal <
global variable
name> <value>]
$libinclude
gnuplotxyz < parameter name> <xaxis element>
<yaxis element>
[$setglobal < global variable name> <value>]
[$libinclude gnuplotxyz < parameter name> <xaxis
element> <yaxis element>]
Note, depending on how many data columns will be provided, gnuplot may use different calculations (see errorlines, errorbars)
$setglobal gp_style
"histogram"
[$setglobal gp_hist "clustered gap 2"]
[$setglobal gp_hist
"rowstacked"]
[$setglobal gp_hist "columnstacked"]
$libinclude gnuplotxyz < parameter
name>
<value>
$setglobal
gp_style " xerrorlines"
$libinclude gnuplotxyz < parameter name> <xvalue>
<yvalue>
<xdelta>
or
$libinclude gnuplotxyz < parameter name> <xvalue> <yvalue>
<xlowvalue>
<xhighvalue>
$setglobal
gp_style " yerrorbars"
$libinclude gnuplotxyz < parameter
name> <xvalue> <yvalue> <ydelta>
or
$libinclude gnuplotxyz < parameter name> <xvalue>
<yvalue> <ylowvalue> <yhighvalue>
$setglobal gp_style "candlesticks"
$libinclude gnuplotxyz < parameter name> <xvalue> <opening value>
<low value> <high
value> <closing
value>
$setglobal
gp_style "
xyerrorlines"
$libinclude
gnuplotxyz < parameter name> <xvalue> <yvalue>
<xdelta> <ydelta>
or
$libinclude gnuplotxyz < parameter name>
<xvalue> <yvalue> <xlowvalue> <xhighvalue>
<ylowvalue> <yhighvalue>
Outside (above) loops:
$libinclude gnuplotxyz loop 2D
[$setglobal gp_loop1
<setname1>]
[$setglobal gp_loop2
<setname2>]
[$setglobal gp_loop3
<setname3>]
[$setglobal gp_loop4
<setname4>]
The statements in
square brackets above are optional. If used, the title of the graph will show
the current element of the loop. You can "unset" the values of these variables by
assigning "no" or "0" (see below).
Inside loops:
$libinclude gnuplotxyz <parameter name> <xaxis
element> <yaxis element>
After loop:
[$setglobal gp_loop1
no]
[$setglobal gp_loop2 no]
[$setglobal gp_loop3 no]
[$setglobal
gp_loop4 no]
The data to be graphed as 3D-plot must be contained in a four dimensional parameter (a parameter which has four sets/indexes/dimensions). The number of elements in the first argument determines the number of different planes in a plot. The number of elements in the second argument determines the number of x-axis values. The number of elements in the third argument determines the number of y-axis values. The order of the elements in the second and third index determines how the different data points pertaining to one plane are connected. The remaining argument (fourth index) must contain at least three set elements of which one represents the x-axis, another one the y-axis coordinate, and a third one the z-axis coordinate.
$libinclude gnuplotxyz <parameter name> <xaxis element> <yaxis element> <zaxis element>
Outside (above) loops:
$libinclude gnuplotxyz loop 3D
[$setglobal gp_loop1 <setname1>]
[$setglobal gp_loop2
<setname2>]
[$setglobal gp_loop3
<setname3>]
[$setglobal gp_loop4
<setname4>]
The statements in square brackets above are
optional. If used, the title of the graph will show the current element of the
loop. You can "unset" the values of these variables by assigning "no" or "0"
(see below).
Inside loops:
$libinclude gnuplotxyz <parameter
name> <xaxis element> <yaxis element>
<zaxis element>
After loop:
[$setglobal
gp_loop1 no]
[$setglobal gp_loop2 no]
[$setglobal gp_loop3
no]
[$setglobal gp_loop4 no]
2D Loop (may not be suitable for all ages)
Through use of global variables, the format of the plot can be changed. If it doesn't work at all or not as you intended, you can examine gnuplotxyz.gms to find out how it is used and to fix the problem.
gp_key, gp_keytitle, gp_keybox, gp_keyopt
gp_color, gp_title, gp_size
gp_style, gp_fill, gp_rectangle, gp_hist
gp_lwidth, gp_pointsz
gp_grid, gp_xgrid, gp_ygrid
gp_zeroax, gp_xzeroax, gp_yzeroax
gp_border, gp_borddim
gp_bmargin, gp_tmargin, gp_rmargin, gp_lmargin (for manually specifying margins)
gp_l1style .. gp_l16style
gp_l1axes .. gp_l16axes
gp_lc_1 .. gp_lc_16 (see available color names )
gp_fixcolor_set (for keeping the same color over a set)
gp_x2axis, gp_y2axis
gp_label, gp_xlabel, gp_ylabel, gp_zlabel, gp_x2label, gp_y2label
gp_ymin (useful when using a 2nd y-axis through y2scale)
gp_y2scale
gp_xrange, gp_yrange, gp_x2range, gp_y2range,
gp_tics, gp_xtics, gp_ytics, gp_xinc, gp_yinc
gp_logscale
gp_supzero
gp_zeroend
gp_label_1 ... gp_label_9
gp_resetstyle
gp_resetaxis
Modifications of gnuplotxyz.gms may be necessary a) to implement additional plotting features and b) to fix bugs. The best way to fix a problem is to work backwards.
Step1: Open and examine the files "gnuplot.inp" and "gnuplot.dat" and determine a) wanted or b) misspecified commands/data (use gnuplot documentation if necessary)
Step2: Create a new file, i.e. "test.gms", in the same directory where "gnuplot.inp" and "gnuplot.dat" are put. The file should have the following content:
execute 'if exist gnuplot.ini del
gnuplot.ini >nul';
execute 'copy gnuplot.inp gnuplot.ini
>nul';
$if "%system.filesys%" ==
"MS95" execute '"%gams.sysdir%inclib\callgplt.bat" x
%gams.sysdir%';
$if "%system.filesys%" ==
"MSNT" execute '"%gams.sysdir%inclib\callgplt.bat"
x';
Step3: Modify "gnuplot.inp" and/or "gnuplot.dat" and test by running "test.gms"
Step4: If you found out how "gnuplot.inp" and/or "gnuplot.dat" should be changed, modify statements in "gnuplotxyz.gms" to produce the desired content in "gnuplot.inp" and/or "gnuplot.dat"