Spreadsheet graphics

Top  Previous  Next

May users of procedures such as Gnuplot and Gnupltxy find themselves wanting more control over the graphics such as provided by Excel among other packages.  One can use the Gdxxrw procedure to gain access to such graphics.  In particular, one can set up a graph in Excel then use Gdxxrw to place new data in the spreadsheet in the area graphed and whenever the spreadsheet is subsequently opened the new and improved graph will be ready.  Let me illustrate this using a new sheet called mygraph in our gdxxrwss.xls.  Here I prepare a graph that uses the data in b2-d7 for the lines and the labels in a11 and a12 to describe those lines.  I would have also liked to use the labels in a13-a15 to name the graph and label it's axes but could not figure a strategy to do this with Excel commands or a simple macro.

 

_img103

 

In turn I go into a GAMS program in this case graphss.gms and put in GDX file creation and Gdxxrw commands

 

set allels /X               X values

            Newline1        Data for line 1

            NewLine2        Data for line 2

            Title           A graph of 2 GAMS generated lines

            XAXIS           Whatever the X axis label

            YAXIS           Whatever the X axis label /

    points /i1*i6/;

table mydata(points,allels) data to graph

          x        NewLine1        NewLine2

i1        1          1

i2        4          3

i3        7          4

i4        8          5

i5        12         8

i6        14         9                ;

mydata(points,"Newline2")=mydata(points,"x")+mydata(points,"Newline1");

 

execute_unload 'tograph.gdx' allels, mydata;

execute 'gdxxrw tograph.gdx trace=3 o=gdxxrwss.xls par=mydata Rng=mygraph!a1:d7';

execute 'gdxxrw tograph.gdx trace=3 o=gdxxrwss.xls set=allels Rng=mygraph!a10 rdim=1';

 

where the Gdxxrw commands save the data to be graphed into the cells a1:d7 and a set using SET where I placed potential titles as explanatory text in cells a10 and below.  In turn when I open the spreadsheet and the mygraph sheet as reproduced below where I find the data, legend and lines graphed have been derived from GAMS.

 

_img104