Updated 12 Jan 2015
SUBPLOT_GRID is a class with which a set of subplots can be created in a space-optimal way. In addition, a figure title and subtitle may be added, as well as specific row and column titles.
Even after resizing, the texts ((sub)figure title and row and column titles) are NOT scaled, keeping the maximum space for the axes.
The SUBPLOTZOOM (combined with maybe ZOOMLINK_AXES) function enables filling the figure window with one or more axes.
The INTERAXES function provides the possibility to show the clicked on data point in an axes, and to shows its values in the title.
The methods LEGEND and COLORBAR ensure a correct handling on zooming and resizing.
Saving the figure to a .fig file, and reloading it via 'openfig' will give a working and fully functionning subplot_grid again. To enable access to the properties and functions/methods, an object called 'o_subplot_grid' is created in the workspace. Within this object all wanted properties and methods can be called.
Available methods (listed alphabetically):
COLORBAR - creates a colorbar to an axes
COLTITLES - Adds column titles (top and bottom are possible, locations can be manually set)
FIGTITLE - Adds a figure title
SUBFIGTITLE - Adds a subtitle
DISABLE_INTERAXES - remove clickable content
DISABLE_SUBPLOTZOOM - remove zoom action
ENABLE_INTERAXES - Enable clickable content
ENABLE_SUBPLOTZOOM - Enable figure filling zoom
EXTRACT_AXES- extract an axes to a new figure
FIGPLACE - grid the figure window or maximize the window
FIGTITLE - add a global figure title
HIDE_AXES - make some axes invisible
HIDE_EMPTY_AXES - hide all empty axes
LEGEND - add a pre-defined legend
OVERWRITE_INTERAXES_SELECTION_MODS - some user-defined modifications for clickable content (interaxes)
REDRAW - redraw the figure (re-align all)
REMOVE_LEGEND - remove legend
ROWTITLES- add texts on the left/right around the axes. Location can be manually set
SET_GCA - set axes to current axes in matlab
SET_PADDING - reset padding around axes
SHOW_AXES - show hidden axes
SUBFIGTITLE - a subtitle
SYNC_AXES - sync x, y or color axes
ZOOMLINK_AXES - link axes on use of subplotzoom.
run 'subplot_grid' for a demo.
The syntax of every method can be found by 'help subplot_grid.<method>'
Joris Kampman (2023). subplot_grid (https://www.mathworks.com/matlabcentral/fileexchange/34191-subplot_grid), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!
Discover Live Editor
Create scripts with code, output, and formatted text in a single executable document.
This version is suitable for R2014b, without any guarantee or expected performance for lower matlab releases (i.e., it is checked for hgVersion 2, and hgVersion 1 is not supported!).
Saving the figure is now possible, and the colorbar is upgraded
fixed minor irritation. Now, after construction of a subplot_grid object, the current axes is set to the first subplot, instead of being left undefined
1. possibility to save a .fig file and load without errors
very stupid bug fixed (seen when only plotting a single axes (subplot_grid(1) crashed)
see 'help subplot_grid'
1: Matched the legend style to MATLAB
some bugfixes on legend placements, and the correct working with zooming in and out.