Obtaining graphical output

Top  Previous  Next

Statements may be entered into a GAMS program that permit graphical displays of data computed during a GAMS run directly in a window on a PC using Rutherford's Gnuplot or Uwe Schneider's Gnupltxy.  To graph data in a GAMS program I need to do three basic things.

Download Schneider's Gnupltxy or Rutherford's Gnuplot software getting both the gms and windows Gnuplot executable.
Fill an internal array.  In the Gnupltxy example simplegr.gms I fill graphdata describing two lines where first dimension is name of line, second number of point on line, and third the x and y data.  Such statements appear below.

 

LINES      Lines in graph /A,B/

POINTS     Points on line /1*10/

ORDINATES  ORDINATES      /X-AXIS,Y-AXIS/  ;

TABLE GRAPHDATA(LINES,POINTS,ORDINATES)

       X-AXIS   Y-AXIS

A.1       1       1

A.2       2       4

A.3       3       9

A.4       5      25

A.5      10     100

B.1       1       2

B.2       3       6

B.3       7      15

B.4      12      36;

 

Then given the data call Gnupltxy which I achieve through the GAMS statement

 

 $LIBINCLUDE Gnupltxy GRAPHDATA Y-AXIS X-AXIS

 

 where the first argument after Gnupltxy gives the array name, the second name of a set element in the third array position which contains the data coordinates for the y axis and the third the name of a set element in the third array position which contains the data coordinates for the x axis.

In turn when I run I get two new windows that automatically open in front of the IDE

 

_img54

 

The window labeled Gnuplot graph is the graph of the data and the window labeled Gnuplot results from the execution of the source Gnuplot program.  Use of such graphing is more extensively discussed and illustrated in the Links to Other Programs Including Spreadsheets chapter.