View License

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video

Highlights from
subplotplus() - Enhanced layout MATLAB subplot function

4.6 | 5 ratings Rate this file 25 Downloads (last 30 days) File Size: 3.83 KB File ID: #34594 Version: 1.1
image thumbnail

subplotplus() - Enhanced layout MATLAB subplot function



14 Jan 2012 (Updated )

subplotplus() is an enhanced alternative to the inherit subplot() function of MATLAB.

| Watch this File

File Information

[subplot_handles,LabelsFontSize] = subplotplus(subplot_array,varargin) is an enhanced alternative to the inherit subplot() function of MATLAB. Using subplotplus() almost any layout of subplots can be created in a particular figure.
The desired subplot layout is described using a complex cell array where each "atomic" cell, within the cell array, corresponds to a subplot. The function scans the content of the input cell array and builds the desired matching subplot layout in the figure. The size, alignment and font size of the subplots is automatically adjusted for best appearance.
The function is recursive in nature so any level of subplot divisions can be created. The returned arguments are the created subplot handles as well as the optimal label (X and Y) font size that should be used for a specific subplot for best appearance.

Input arguments:
+ subplot_array: A cell array that describes the desired subplot layput. For example, a 1x2 subplot layout where the right-end subplot is further divided down to a column of 3 additional subplots is described by the following cell expression: {{[]},{{[]};{[]};{[]}}}.
A group of subplot cells, sharing the same "parent" cell, can be glued together in order to save figure space using the '-g' option string at the cell's content (instead of empty group []). For example, if the 3 columned subplots of the previous example are to be glued together, sharing the same X-axis, the follwing cell expression should be used:
+ varargin: only used for function recursion and should not be used by the user.

Output arguments:
+ subplot_handles: A list of the created subplot handles by their order of appearnace in the figure, starting from the left-top corner in a clockwise manner.
+ LabelsFontSize: A matching list of X/Y-axis optimal labels size for further user work on the subplots.

Alon Geva
$Revision: 1.00 $ $Date: 12/01/2012 18:52:53 $


This file inspired Subtightplot.

Required Products MATLAB
MATLAB release MATLAB 7.8 (R2009a)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (5)
15 Aug 2015 Adam Danz

Adam Danz (view profile)

22 Jan 2015 Helene Kolding

Very nice

I want to place seven graphs vertically, and only have the middle five glued together. This can be done, but it "unlocks" the x-axis for these five graphs, so it does not line up with the other.

I've used
And variations thereof.


07 Jul 2014 James

James (view profile)

20 Aug 2013 Jerry Gregoire

Would like to see it able to pass parameters pairs to subplots,
For Example: {{'-g' 'XGrid' 'off'}}

You can use repmat to simplify the structure generation,
(ie) Plot3Vert = repmat({{'-g'}},3,1);
will produce 3 subplots 'glued' on top or each other. That's nice.

Otherwise good for producing pretty complex figures.

Syntax reminds me of Lisp.

08 Nov 2012 Marzieh


18 Jan 2012 1.1

Fixing an error in the descreption text:
"following cell expression: {{[]},{{[]};{[]};{[]}}}..." instead of:
"following cell expression: {{[]},{{[]};{[]} {[]}}}..."

Contact us