Search code examples
matlabmatlab-figure

Add complete 6 borders for 3D figure


I use surf to plot 3D surface, and I try to add borders using "box on", but it can only show 3 borders. see

enter image description here

However, What I really want is to add all 6 borders for the cube, like this

enter image description here.

Could anyone tell me how to do that?


Solution

  • You need to change the axes BoxStyle to 'full', with the Box on. For example:

    [x,y] = meshgrid( 0:0.1:6, 0:0.1:6 );
    surf( x, y, cos(x)+sin(y), 'LineStyle', 'none' );
    set( gca, 'Box', 'on', 'BoxStyle', 'full' );
    

    plot