Updated 6 Mar 2015
tightPlots is a function that allows making single plots or subplots with controlled size and margins. The desired (page) width, aspect ratio and margins must be input, with which the appropriate height is calculated.
This workflow allows for all figures to maintain font formatting when they are inserted into a document/publication. Adjust the width to match the document page width and fix the font size. Narrow plots can then be created by Setting wide side margins.
The function additionally creates a bounding box equal to the figure size on the screen. As a result, what is seen on the monitor can be printed in both raster (.png) and vector (.eps, .pdf) formats with the same result.
tightPlots has been influenced by the "tight_subplot" function of Pekka Kumpulainen, hence, parts of the code and parameter names were kept the same.
Theo Michelis (2023). tightPlots (https://www.mathworks.com/matlabcentral/fileexchange/45380-tightplots), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
- MATLAB > Graphics > Formatting and Annotation > Axes Appearance > Aspect Ratios and Layout >
- MATLAB > Graphics > Formatting and Annotation > Axes Appearance > Combine Multiple Plots > Subplots >
Inspired by: tight_subplot(Nh, Nw, gap, marg_h, marg_w)
Inspired: Remove White Space，Make Subplot Tight, smplot for small multiples
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.
Changes for compatibility with MATLAB 2014b versions and above.
1) Description extension
Tested with Matlab versions 2012a, 2012b, 2013a, 2013b and 2014a
Change of additional axis settings.
Worked around a cropped bounding box issue when exporting to post script by introducing an additional axis.
Resizing of figure with mouse is no longer allowed. Small change in example 1, for better demonstration.