Resizable MATLAB figures

A simple mechanism for creating graphical user interfaces which resize tidily
3.6K Downloads
Updated 1 Sep 2016

View License

This is a layout manager for axes and controls in a MATLAB figure, designed for graphical user interfaces in which, during resizing of the figure, some controls (e.g. buttons) are to remain the same size while others (e.g. axes, text fields, list boxes) are to change size.
To achieve this, the figure is split into a grid with a border and with spacing between each cell. Some rows and columns (at least one of each) are variable in size and the rest are fixed. When the figure is resized, the available space (i.e. that not required by the fixed-size rows and columns) is distributed among the variable-sized ones according to a specified ratio. If there is not enough space for the fixed-size rows or columns, these (and the spacing between them) will be made smaller too.

Controls can be merged across multiple rows and/or columns and can overlap (making it possible to put a frame round other controls).

Example code is provided. The basic sequence is:
* Create figure (using the supplied function "resizable_figure")
* Create controls (axes, uicontrols, ActiveX controls, java components)
* Create an "elements" cell-matrix to specify top-right positions for controls.
* Create a "mergeblocks" matrix giving sizes for components which span more than one cell in the grid
* Specify row and column sizes (positive sizes are specify fixed sizes in pixels, negative ones give the ratios for resizable rows and columns)
* Set the initial size for the figure and show it

The code has been tested with MATLAB 6.1 (R12.1) through MATLAB 7.1 (R14sp3).

Cite As

Malcolm Wood (2024). Resizable MATLAB figures (https://www.mathworks.com/matlabcentral/fileexchange/10309-resizable-matlab-figures), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R12.1
Compatible with any release
Platform Compatibility
Windows macOS Linux
Categories
Find more on Migrate GUIDE Apps in Help Center and MATLAB Answers
Acknowledgements

Inspired: Yet Another Layout Manager

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.2.0.1

Updated license

1.2.0.0

Added copyright statements, and eliminated the need for a P-coded file.

1.1.0.0

Review

1.0.0.0

Added a published M-file example