gridlines, a MATLAB code which draws grid lines on MATLAB plots.

MATLAB's plotting commands include the "grid on" option, which places a certain number of grid lines on your plot. However, if you don't like the choice of placement, linestyle, coloring, or the number of grid lines, changing these features, while possible, requires an extensive trip through MATLAB's plotting underworld.

But gridlines are just lines, and you can use the line command to draw them. The functions provided here do just that, with a reasonable interface that lets you select where and how many lines you want. If you look inside the text of the functions, you can easily modify other features, such as the line color.


The computer code and data files described and made available on this web page are distributed under the GNU LGPL license.


gridlines is available in a MATLAB version.

Related Data and Programs:

cc_display, a MATLAB code which displays the abscissas used in various kinds of Clenshaw Curtis quadrature rules.

circles, a MATLAB code which can be used, when creating graphics, to draw one or more circles, while controlling the center locations, radii, colors, edge colors, and transparency, by Chad Greene.

gl_display, a MATLAB code which displays the abscissas used in various kinds of Gauss Legendre quadrature rules.

grid_display, a MATLAB code which can display a 2D or 3D grid or sparse grid.


mesh_display, a MATLAB code which reads data defining a polygonal mesh and displays it, with optional numbering.

nested_sequence_display, a MATLAB code which displays a set of nested sequences.

sequence_streak_display, a MATLAB code which displays a "streak plot" of a numeric sequence;

triangulation_display, a MATLAB code which displays the nodes and elements of a triangulation on the MATLAB graphics screen;

Source Code:

Last revised on 24 January 2019.