11.117 Sample ‘step

Function step plot data as stairs. At this stairs can be centered if sizes are differ by 1.

MGL code:

call 'prepare1d'
origin 0 0 0:subplot 2 2 0 '':title 'Step plot (default)':box:step y
new yc 30 'sin(pi*x)':new xc 30 'cos(pi*x)':new z 30 'x'
subplot 2 2 1:title '3d variant':rotate 50 60:box:step xc yc z 'r'
subplot 2 2 2 '':title '"!" style':box:step y 's!rgb'

C++ code:

void smgl_step(mglGraph *gr)
{
	mglData y;	mgls_prepare1d(&y);	gr->SetOrigin(0,0,0);
	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)");
	if(big!=3)	{	gr->SubPlot(2,2,0,"");	gr->Title("Step plot (default)");	}
	gr->Box();	gr->Step(y);
	if(big==3)	return;
	gr->SubPlot(2,2,1);	gr->Title("3d variant");	gr->Rotate(50,60);
	gr->Box();	gr->Step(xc,yc,z,"r");
	gr->SubPlot(2,2,2,"");	gr->Title("'!' style");	gr->Box();	gr->Step(y,"s!rgb");
}
Sample step