Add Grid Lines to a MATLAB Plot

**GRIDLINES**
is a MATLAB library which
contains routines to draw 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.

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

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

GRID_DISPLAY, a MATLAB library which can display a 2D or 3D grid or sparse grid.

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

NESTED_SEQUENCE_DISPLAY, a MATLAB program which displays a set of nested sequences.

SEQUENCE_STREAK_DISPLAY, a MATLAB program which displays a "streak plot" of a numeric sequence;

TRIANGULATION_DISPLAY, a MATLAB program which displays the nodes and elements of a triangulation on the MATLAB graphics screen;

XY_DISPLAY, a MATLAB program which reads a set of 2D points from a file and plots them in a the MATLAB graphics window.

XYF_DISPLAY, a MATLAB program which reads XYF information defining points and faces in 2D, and displays an image in a MATLAB graphics window.

XYL_DISPLAY, a MATLAB program which reads XYL information defining points and lines in 2D, and displays an image in a MATLAB graphics window.

XYZ_DISPLAY, a MATLAB program which reads a set of 3D points from a file and plots them in a the MATLAB graphics window.

- circular_arc.m draws a circle, or circular arc.
- grid_polar.m draws a polar grid, that is, NR circular arcs between RMIN and RMAX, drawn at NANG equally spaced angles between ANGMIN and ANGMAX.
- grid_rectangular.m draws a rectangular grid, that is, XNUM vertical lines between XMIN and XMAX, and YNUM horizontal lines between YMIN and YMAX.
- grid_triangular.m draws a triangular grid, drawing NGRID equally spaced lines parallel to each side of a triangle.
- timestamp.m prints the YMDHMS date as a timestamp.

- gridlines_test.m, calls all the tests.
- gridlines_test01.m, plots 100 random points, and draws an 11 by 11 grid.
- gridlines_test01.png, a PNG image of the plot.
- gridlines_test02.m, plots 400 random points in the upper half circle, using R = sqrt ( rand ), and 400 points in the lower half circle, using R = rand.
- gridlines_test02.png, a PNG image of the plot.
- gridlines_test03.m, draws two triangular grids on one plot; the larger triangle has 10 interior grid lines in each direction, the smaller has 3.
- gridlines_test03.png, a PNG image of the plot.

You can go up one level to the MATLAB source codes.