Limit figure size

Version (3.53 KB) by Jan
Set minimal or maximal size of a figure


Updated 29 Feb 2016

View License

LimitSizeFig - Set minimum and maximum figure size
Some dialogs become ugly, if their size is getting too small. Setting a minimal size in the figure's ResizeFcn leads to strange effects, when the left side of the figure is dragged. This function calls Java to limit the figure size.
LimitSizeFig(FigH, Prop, Ext)
FigH: Handle of a Matlab figure.
Prop: String, command:
'min', 'max': Set minimum or maximum extent.
'get': Reply the limits.
'clear': Clear both limits.
Ext: Extent as [1 x 2] vector, minimal width and height in pixels.
FigH = figure;
LimitSizeFig(FigH, 'min', [200, 200])
LimitSizeFig('max', [400, 400]) % Uses GCF
Limit = LimitSizeFig(FigH, 'get')

Tested: Matlab 7.7, 7.8, 7.13, 8.6, HG2, WinXP/32, Win7/64
Run the unit-test uTest_LimitSizeFig to check the validity on your Matlab version.

Cite As

Jan (2023). Limit figure size (, MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2015b
Compatible with any release
Platform Compatibility
Windows macOS Linux
Find more on Call Web Services from MATLAB Using HTTP in Help Center and MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes

Adjutsed to R2015b
Mentioned compatibility with HG2.