GraphiC Sample Code:

Below is a copy of a simple 'C' program which generates an array of 300 data points and uses GraphiC to create a linear plot.

View the equivalent Fortran GraphiC program.

View the equivalent Visual Basic GraphiC program.

View the program output.

/****************************************************************************
    (c) 1984-1993 by Scientific Endeavors Corporation.
    All rights reserved.

    This program plots a single curve on a set of 2-D linear axes. Except for
    color(), sympick(), and grid(), this simple example program uses only
    the minimum calls needed to produce a GraphiC plot.
****************************************************************************/

#include <graphic.h>                           /* Include all needed files */

#if TCQ                                 /* Set stack for Borland (Turbo) C */
extern unsigned _stklen = 0x3000;
#endif

/****************************************************************************
    Main program
****************************************************************************/
void GPC_MAIN(void)
{
    float *x, *y;
    int i, nxdiv, nydiv, npts;
    npts = 301;                      /* The # of points in x and y vectors */

    x = (float *)gpcalloc(npts, sizeof(float));
    y = (float *)gpcalloc(npts, sizeof(float));
    if(x == (float *)NULL || y == (float *)NULL) {
        GPC_PUTS("SAMPLE: Could not allocate data arrays");
        goto EndOfApp;
    }
    
    bgnplot(1, 't', "sample.tkf");     /* Parameters: 1 - draw plot on screen
                                            'g' - graphics
                                            mode
                                           "sample.tkf" - .TKF file name   */
    startplot(WHITE);
    metricunits(0);                        /* Ensure scaling in inch units */
    font(1, "simplex.fnt", '\310');              /* Loads your chosen font */
    page(9.0f, 6.884f);                              /* Sets the page size */
                  /* This is the same aspect ratio as 4095 by 3132 */
    area2d(7.6f, 5.5f);                       /* Sets the area of the plot */
    for (i = 0; i < npts; i++) {                       /* Generate data */
        y[i] = .3f * i;
        x[i] = (y[i] * y[i]) / 2.f;
    }
    color(BLACK);                  /* Axis names and heading will be black */
    xname("\310X-Axis");
    yname("Y-Axis");
    heading("SAMPLE PLOT");
    grid(9);                /* Draws grid through tick marks, 9 - fine dot */
    nxdiv = 5;                   /* Sets the desired # of x-axis divisions */
    nydiv = 6;                   /* Sets the desired # of y-axis divisions */
    color(GREEN);                                 /* Green axes and labels */
    scales(nxdiv, nydiv, x, y, npts);         /* Draws and scales the axes */
    color(RED);                                               /* Red curve */
    sympick(12);                                  /* Filled circle symbols */
    curve(x, y, npts, 10);
    endplot();         /* Finishes plot and waits for instructions to exit or
                 draw next plot. Resets file pointers and defaults */
    stopplot();          /* Close files, return to text mode, exit program */
EndOfApp:
    gpcfree((void **)&x);
    gpcfree((void **)&y);
}