grid2 - add a grid to 2D plots

This function adds a grid to a 2D plot which can be modified.

You are now following this Submission

This function adds a grid to 2D plots. The grid contains out of lines which can be modified by linestyles and color information. This function expands the functionality of the normal grid implemented in MATLAB plots.

plot(rand(1,10));
set(gcf,'color',[1 1 1]);
grid2(gca,'color',[0.7 0.7 0.7],'linewidth',3);

Cite As

Stefan Schuberth (2026). grid2 - add a grid to 2D plots (https://se.mathworks.com/matlabcentral/fileexchange/8758-grid2-add-a-grid-to-2d-plots), MATLAB Central File Exchange. Retrieved .

General Information

MATLAB Release Compatibility

  • Compatible with any release

Platform Compatibility

  • Windows
  • macOS
  • Linux
Version Published Release Notes Action
1.0.0.0

Example added