#include <oxstd.h>
#include <oxdraw.h>
// test of various graphics functions
main()
{
    decl m = rann(30,2);
    Draw(0, m', 0, 1);                    // draw 2 variables
    DrawAdjust(ADJ_MINMAX, -5, 5);        // adjust y min/max
    DrawTitle(0, "A title");                 // set the title
    DrawText(0, "Maths: $\\theta_i$", 1, 3); // text at (1,3)
                             // add text at pixel coordinates
    DrawPText(0, "at pixel (1000,3000)", 1000, 3000, 0, 400);
    
    DrawBoxPlot(1, m[][0]', "Var1");       // draw a box plot
    DrawLine(1, 0, -1, 1, 1, 4);     //and a line in the plot
         // draw a circle, is in area 2 but belongs to area 1
    DrawPSymbol(1, 3000, 3000, 4000, 4000, PL_CIRCLE,3);
    DrawAxisAuto(1, FALSE);            // draw default y axis
                                       // add a second y axis
    DrawAxis(1, FALSE, 2, -1, 1, -1, 0.5, 0.1, 0);
    DrawAdjust(ADJ_AXISLINE, 0, 1, 1, 0);      // adjust axis
                                         // draw a cross plot
    DrawXMatrix(2, m[][0]', "Var1", m[][1]', "Var2");
    DrawAdjust(ADJ_INDEX, 1, -1);     // change to index line
    DrawLegend(2, 0, 0, 1);                // hide the legend

    DrawTMatrix(3, m[][0]', "Var1", 1960, 1, 4);      // draw
    DrawZ(m[][1]');               // add 2nd var as error bar
    DrawLegend(3, 100, 50, 0);             // draw the legend
    DrawAdjust(ADJ_AREA_X, 3, 1959, 1968);     //fix x(world)
                         // also fix pixel location of area 3
    DrawAdjust(ADJ_AREA_P, 3, 9000, 1500, 5000, 3000);

    DrawTMatrix(4, m[][1]', "Var2", 1960, 1, 4, 0, 3);
                              // draw area 4 on top of area 3
    DrawAdjust(ADJ_AREA_P, 4, 9000, 1500, 5000, 3000);
    DrawAdjust(ADJ_AREA_X, 4, 1959, 1968);     //same x world
    DrawAxisAuto(4, TRUE, FALSE);            // remove x axis
    DrawAxisAuto(4, FALSE, TRUE, ANCHOR_MAX);     //move axis
    DrawAdjust(ADJ_AXISLINE, TRUE, TRUE);     // labels right
    DrawLegend(4, 550, 50, 0);                 // move legend

    DrawPText(4, "Var1 on left scale",  9100, 700);
    DrawPText(4, "Var2 on right scale", 9100, 400);

    DrawAdjust(ADJ_AREAMATRIX, 2, 2);     // 5 areas, use 2x2

    ShowDrawWindow();                 // show this concoction
    SaveDrawWindow("draw4.gwg");
    SaveDrawWindow("draw4.eps");
}
