11.5 Sample ‘area

Function area fill the area between curve and axis plane. It support gradient filling if 2 colors per curve is specified.

MGL code:

call 'prepare1d'
origin 0 0 0
subplot 2 2 0 '':title 'Area plot (default)':box:area y
subplot 2 2 1 '':title '2 colors':box:area y 'cbgGyr'
subplot 2 2 2 '':title '"!" style':box:area y '!'
new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'
subplot 2 2 3:title '3d variant':rotate 50 60:box
area xc yc z 'r'
area xc -yc z 'b#'

C++ code:

void smgl_area(mglGraph *gr)
{
	mglData y;	mgls_prepare1d(&y);	gr->SetOrigin(0,0,0);
	if(big!=3)	{	gr->SubPlot(2,2,0,"");	gr->Title("Area plot (default)");	}
	gr->Box();	gr->Area(y);
	if(big==3)	return;
	gr->SubPlot(2,2,1,"");	gr->Title("2 colors");	gr->Box();	gr->Area(y,"cbgGyr");
	gr->SubPlot(2,2,2,"");	gr->Title("'!' style");	gr->Box();	gr->Area(y,"!");
	gr->SubPlot(2,2,3);	gr->Title("3d variant");	gr->Rotate(50,60);	gr->Box();
	mglData yc(30), xc(30), z(30);	z.Modify("2*x-1");
	yc.Modify("sin(pi*(2*x-1))");	xc.Modify("cos(pi*2*x-pi)");
	gr->Area(xc,yc,z,"r");
	yc.Modify("-sin(pi*(2*x-1))");	gr->Area(xc,yc,z,"b#");
}
Sample area