Dec 082017
 
Turbo C source code that will take an array and plot it on a labeled axes.
File TCPLOT.ZIP from The Programmer’s Corner in
Category C Source Code
Turbo C source code that will take an array and plot it on a labeled axes.
File Name File Size Zip Size Zip Type
PLOT.C 33161 5643 deflated
PLOT.DOC 7441 2043 deflated

Download File TCPLOT.ZIP Here

Contents of the PLOT.DOC file


Turbo C Plotting Package

Michael R. Greason
7 June 1989

Turbo C comes with a rich set of plotting functions; however,
these are all geared toward direct screen manipulation, with the
coordinates supplied being the actual screen coordinates. A package
capable of taking an array and plotting it on labeled axes is very
useful and is described here.

There are many functions involved in this package. Nearly all
the functions used by the user are declared VOID. These user functions
will be described below.

User Functions

Several of the functions described below require a parameter
describing the variable type of the data passed to the function. This
parameter will be called the VTYPE, is of type INT, and is defined as
follows:
0 -- Short INT
1 -- INT
2 -- Long INT
3 -- Float
4 -- Double



gr_closeplot

This function is used to terminate a plotting session (not an
individual plot).

Parameters:None.

Returned:None.

gr_clrscn

Wipes the screen of everything on it.

Parameters:None.

Returned:None.

gr_openplot

This function must be the first called in a plotting session.
It initializes the status variables (variables the user should leave
alone) and the device.

Parameters:None.

Returned:INT An error flag is returned. A 0 indicates
success while a 1 indicates an initialization
failure.

gr_oplot

Overplots two arrays on an already defined set of axes.

Parameters:N INT The number of points to plot.
*X VOID A pointer to the array of x coordinates
to plot.
*Y VOID A pointer to the array of y coordinates
to plot.
VTYPE See above.

Returned:None.

gr_oplot1

Overplots a single array on an already defined set of axes. The
abcissa is assumed to be the indices of the array.

Parameters:N INT The number of points to plot.
*Y VOID A pointer to the array of y coordinates
to plot.
VTYPE See above.

Returned:None.

gr_plot

Plots two arrays defining a set of axes.

Parameters:N INT The number of points to plot.
*X VOID A pointer to the array of x coordinates
to plot.
*Y VOID A pointer to the array of y coordinates
to plot.
VTYPE See above.

Returned:None.

gr_plot1

Plots a single array, defining a set of axes. The abcissa is
assumed to be the indices of the array.

Parameters:N INT The number of points to plot.
*Y VOID A pointer to the array of y coordinates
to plot.
VTYPE See above.

Returned:None.

gr_setaxes

Sets up the axial plot information in the status variables. The
plot's main title, axes titles, and axes descriptor are passed through here.

Parameters:DISPINTThe display status word. This
word is used to describe how to
display the axes. It is
bit-coded as follows:
Bit 0 -- Box (set) or half-box (clear)
Bit 1 -- Display ticks (set)
Bit 2 -- Ticks out of box (set)
or in box (clear)
Bit 3 -- Numerical labeling (set)
Bit 4 -- Display title (set)
Bit 5 -- Display axes (set).
*MTITCHARThe plot's title.
*XTITCHARThe X axis title.
*YTITCHARThe Y axis title.

Returned:None.

gr_seterase

Sets up the erasure information in the status variables. If
passed a zero, the screen will not be erased between new plots.

Parameters:FLAGINTIf nonzero, erase the plot at
the start of each call to
GR_PLOT or GR_PLOT1.

Returned:None.

gr_setlinestyle

Defines the line style used when plotting a line.

Parameters:STYLEINTThe linestyle:
solid -- 0
dotted -- 1
center -- 2
dashed -- 3
THICKINTThe line thickness. There are
two choices: normal (1) or
thick (3).

Returned:None.

gr_setscreen

Defines the region on the screen to use in displaying the actual
plot. Titles and numerical labeling are placed outside of this region.
The coordinates supplied are screen coordinates. Remember, these
numbers have their origin in the upper left corner of the screen. The
lower y axis is defined as the smaller of the two y axis limits.

Parameters:XMININTThe lower x axis screen limit.
XMAXINTThe upper x axis screen limit.
YMININTThe lower y axis screen limit.
YMAXINTThe upper y axis screen limit.

Returned:None.

gr_setsymbol

Indicates what sort of symbol to use in displaying the data.

Parameters:SYMINTThe symbol to use. The values are:
0 -- a line (default)
1 -- '1'
2 -- '2'
3 -- '3'
4 -- '4'
5 -- '5'
6 -- '6'
7 -- '7'
8 -- '8'
9 -- '9'
10 -- '0'
11 -- 'X'
12 -- '*'
13 -- 'O'
14 -- '+'

Returned:None.

gr_setviewport

Defines the region on the screen to use in displaying the actual
plot. Titles and numerical labeling are placed outside of this region.
The coordinates supplied are fractions of the screen.Remember, these
numbers have their origin in the upper left corner of the screen. The
lower y axis is defined as the smaller of the two y axis limits.

Parameters:XMININTThe lower x axis limit.
XMAXINTThe upper x axis limit.
YMININTThe lower y axis limit.
YMAXINTThe upper y axis limit.

Returned:None.

gr_setxy

Allows the user to manually dictate what the minimum and maximum
values are in each direction. The value-to-screen functions are derived
from the values passed to this function.

Parameters:XMINFLOATThe minimum x axis value.
XMAXFLOATThe maximum x axis value.
YMINFLOATThe minimum y axis value.
YMAXFLOATThe maximum y axis value.
AUTINTTurns on/off autoscaling. If
set to zero, the manual scaling
supplied is used; else,
autoscaling is done.

Returned:None.

gr_textscn

Permits the user to put text at the supplied screen coordinates.

Parameters:*STR CHAR The string to output.
*X VOID The x screen coordinate to start the
string.
*Y VOID The y screen coordiante to start the
string.
DIR INT The direction of the string, HORIZ_DIR
(<= 0) or VERT_DIR (>= 1).
SIZ INT The character size. Each character is
defined as 8x8 pixels; this number is a
multiplier and is defined from 1 to 10.
VTYPE See above.

Returned:None.

gr_textlog

Permits the user to put text at the supplied logical values.

Parameters:*STR CHAR The string to output.
*X VOID The x logical coordinate to start the
string.
*Y VOID The y logical coordinate to start the
string.
DIR INT The direction of the string, HORIZ_DIR
(<= 0) or VERT_DIR (>= 1).
SIZ INT The character size. Each character is
defined as 8x8 pixels; this number is a
multiplier and is defined from 1 to 10.
VTYPE See above.

Returned:None.

gr_histogram

Plots a single array as a histogram. The abcissa is assumed
to be the indices of the array.

Parameters:N INT The number of points to plot.
*Y VOID A pointer to the array of y coordinates
to plot.
VTYPE See above.

Returned:None.



 December 8, 2017  Add comments

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)