

Plotting graphs and charts
When we need to plot a graph of any given function, we face the problem of
interfacing the computer coordinate system. The figure below shows the computer
coordinate system at a resolution of 640x480.
As shown in the figure, the direction of the positive Yaxis is opposite
to the one used in engineering charts. So, we have to consider this when
rescaling and translating the axes.
Almost all monitors connected to PCs today support the VGA resolution of
640x480x16, which is supported by Borland and Turbo C, and most other C compilers.
So, we will use this mode in all our examples.
We will use a function screen_x() that returns the actual screen Xcoordinate
given the begining and end Xcoordinates, xb and xe resp., and the desired
Xcoordinate. The relation between all these is shown in the figure below.
Another function, screen_y() does the same on Ycoordinates.Here is the
readytouse code for both functions:
Usage of both of the above functions is illustrated by the following examples:
Plotting the quadratic function y=ax^{2}+bx+c
Zooming and panninggraphs in action!
Plotting data from a file

