version (90.8 KB) by Phil
Adds a customisable grid to a 2D plot


Updated 20 Feb 2015

View License

Enables the custom setting of the position of an axes grid lines on a 2D plot. Grid lines can be arbitrary placed on figure axes with customisable colour, width, line styles and alpha. The user can also supply a set of X and Y points to define their own grid lines, e.g. at 45 degrees or curved grids.
To enable alpha blending of the lines in order to mimic Matlab's grid function the lines are drawn as the edges of patches using Brett Shoelson's patchline function. This was released for Matlab 2012 and providing this works, there is no reason this function should not work in earlier versions of Matlab.

Cite As

Phil (2022). customGrid (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2014a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Inspired by: Patchline

Community Treasure Hunt

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

Start Hunting!