Code covered by the BSD License  

Highlights from

5.0 | 8 ratings Rate this file 158 Downloads (last 30 days) File Size: 122 KB File ID: #39664
image thumbnail



Felipe G. Nievinski


28 Dec 2012 (Updated )

Asymmetric subplots with variable inner gaps and outer margins.

| Watch this File

File Information

subtightplot is a merger of Pekka Kumpulainen's tight_subplot and Nikolay S.'s subplot_tight. It extends the former, which supports asymmetric subplots, to allow for variable margins in addition to gaps, as in the latter.

Existing scripts that currently call Matlab's builtin subplot can be adapted with minimal modification by issuing the following command upfront:
  subplot = @(m,n,p) subtightplot(m,n,p,opt{:});
where opt = {gap, width_h, width_w} describes the inner and outer spacings. The screenshot attached shows demo results for examples modified from the subplot documentation.

For axes ticks and labels and locations, see Matlab's axes properties documentation, or try Eran Ofek's subplot1 for a more guided approach.

If you prefer a post-processing solution, see Richard Crozier's tightfig or Aditya's spaceplots.

Alon Geva's subplotplus is interesting for making complicated subplot arrangements; apparently gaps and margins are fixed. Aslak Grinsted's subaxis is based on a richer, more expressive HTML jargon. Joris Kampman's subplot_grid is a colossal 3500+ line object-based implementation. These high-end alternatives are a departure from the built-in subplot's calling syntax, though.

For an overview, please see the Dec 21st, 2012 post on the File Exchange Pick of the Week Blog, titled "Figure margins, subplot spacings, and moreā€¦".


An Improved Subplot Function, Tightfig, Subplotplus() Enhanced Layout Matlab Subplot Function, Spaceplots, Tight Subplot, Controllable Tight Subplot, Subaxis Subplot, and Subplot Grid inspired this file.

This file inspired Dicom Operator Esme Process and Natural Gas Storage Valuation.

Required Products MATLAB
MATLAB release MATLAB 7.13 (R2011b)
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (9)
08 Sep 2014 Martin


thank you :-)

13 Aug 2014 schwarzkater


Excellent! Thanks a lot

24 Jun 2014 Anton Semechko

Anton Semechko

06 May 2014 Felipe G. Nievinski

Felipe G. Nievinski

@Tamanaco: clear subplot;

Comment only
06 May 2014 Tamanaco


Hi Felipe! How do you revert the
subplot = @(m,n,p) subtightplot(m,n,p,opt{:});
assignment back to the original Matlab subplot function? Regards and thanks!

10 Jan 2014 Joshua Carmichael

Joshua Carmichael

Excellent utility, and works well with export_fig. I implement it with all of my tools.

02 Nov 2013 Julian Gallego

Julian Gallego

08 May 2013 K Y


really useful for me
many thanks

15 Jan 2013 Alexander


Very useful. Thought of writing it myself before found this submission.

02 Jan 2013

acknowledged one more FX submission.

08 Jan 2013

acknowledging another FX submission.

Contact us