Programming and Graphics

(Kiana) #1

7.5 A graph with axes 229


int main()
{
float points[4][2];

//--- Define the data to be plotted:

...

//--- Define plotting parameters:

...

//--- Graphics:

float xmarg = 0.2*(xmax-xmin); // plotting margin
float ymarg = 0.2*(ymax-ymin);
int Icheck;

again:

prefposition (500,100);
prefsize (500,500);
vinit ("X11");
short Itry = 0;
short Iplot = 0;

repeat:

ortho2 (xmin-xmarg,xmax+xmarg,ymin-ymarg,ymax+ymarg);
color (YELLOW);
clear();

//--- Repaint the plotting area:

if(Iplot==4 || Iplot==6)
{
points[1][1] = xmin;
points[1][2] = ymin;
points[2][1] = xmax;
points[2][2] = ymin;
points[3][1] = xmax;
points[3][2] = ymax;
points[4][1] = xmin;
points[4][2] = ymax;
poly2 (4,points);
}

//--- draw markers
Free download pdf