GNUPLOTXYZ.GMS - A Windows based GAMS Interface to GNUPLOT 4.4
Uwe A. Schneider
May 25, 2010
Credits
Description
Download
2D
Syntax
3D
Syntax
Examples
Options
Modification
Other GAMS interfaces from/to: ShadeMap Gnuplot Stata Powerpoint Html Awk
Join
gnuplotxyz discussion forum http://groups.google.com/group/gnuplotxyz
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 . 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.
wingnuplot44.7z contains the gnuplot files. Extract these files to the GAMS system directory using 7z or other suitable software. Alternatively, you can download the files directly from the official gnuplot home page.
inclib.7z includes two files ("callgplt.bat" and "rt1.exe") which must be extracted to the .\inclib subdirectory of your GAMS system directory
gnuplotxyz.gms contains the most recent version of this file. It should be extracted to the .\inclib subdirectory of your 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)
Applies automatically to parameters with 2 indexes. Only use one argument after $libinclude gnuplotxyz!
[$setglobal gp_hist "clustered gap 2"]
[$setglobal gp_hist "rowstacked"]
[$setglobal gp_hist "columnstacked"]
$libinclude gnuplotxyz <
parameter name>
Applies automatically to parameters with 3 indexes and one argument after $libinclude gnuplotxyz.
$libinclude gnuplotxyz < parameter name>$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
[$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
[$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]
normal 2D Histograms (html, ppt)
new 3 dimensional 2D Histograms (html, ppt)
new assign some elements of 2D Histograms to second y (y2) axis (html)
2D Fill Space between lines (html, ppt)
2D Loop (may not be suitable for all ages ;)
TextLabels (html, ppt)
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_term wxt
other terminal types include emf, gif, .. some options will not work properly with non-windows terminals
(these form entire lines befoe the plot statement in the gnuplot.inp file)
gp_option_1, ..., gp_option_4
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_lw_1, ... gp_lw_16 (for specifying the width of individual lines)
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"