11.121 Sample ‘surf

Function surf is most standard way to visualize 2D data array. Surf use color scheme for coloring (see Color scheme). You can use ‘#’ style for drawing black meshes on the surface.

MGL code:

call 'prepare2d'
subplot 2 2 0:title 'Surf plot (default)':rotate 50 60:light on:box:surf a
subplot 2 2 1:title '"\#" style; meshnum 10':rotate 50 60:box:surf a '#'; meshnum 10
subplot 2 2 2:title '"." style':rotate 50 60:box:surf a '.'
new x 50 40 '0.8*sin(pi*x)*sin(pi*(y+1)/2)'
new y 50 40 '0.8*cos(pi*x)*sin(pi*(y+1)/2)'
new z 50 40 '0.8*cos(pi*(y+1)/2)'
subplot 2 2 3:title 'parametric form':rotate 50 60:box:surf x y z 'BbwrR'

C++ code:

void smgl_surf3(mglGraph *gr)
{
	mglData c;	mgls_prepare3d(&c);
	if(big!=3)	{	gr->SubPlot(2,2,0);	gr->Title("Surf3 plot (default)");	}
	gr->Rotate(50,60);	gr->Light(true);	gr->Alpha(true);
	gr->Box();	gr->Surf3(c);
	if(big==3)	return;
	gr->SubPlot(2,2,1);	gr->Title("'\\#' style");
	gr->Rotate(50,60);	gr->Box();	gr->Surf3(c,"#");
	gr->SubPlot(2,2,2);	gr->Title("'.' style");
	gr->Rotate(50,60);	gr->Box();	gr->Surf3(c,".");
}
Sample surf