给你举个例子
rectangle( 'Position', [ 1, 2, 5, 10 ], 'FaceColor', [ 0, 0.5, 0.5 ], 'EdgeColor', 'b', 'LineWidth', 3 );
set( gca, 'XGrid', 'on', 'Layer', 'top' );
set( gca, 'YGrid', 'on', 'Layer', 'top' );
这样就可以把网格线设置到 rectangle 所绘图形图层的上面了

Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!