Auto resize of manually added axes

3 views (last 30 days)
Michael on 22 Jun 2021
Commented: DGM on 22 Jun 2021
I need to manually add axes to a figure, but I want the axes I add to automatically resize when I maximize/scale the figure window. When I create the axes using 'subplot.m,' the axes scale when I maximize the window, which is what I want. When mannually adding axes (see code below) the resulting axes don't grow with the window size. How might I do this?
fig_h = figure;
ax_h = uiaxes(fig_h);
I've looked through both the axes and figure object properties for a something related to auto resizing, but haven't found anything. Any bright ideas would be appreciated.
DGM on 22 Jun 2021
Two things:
1: What is the 'units' property of the axes object set to? If it's not set to 'normalized', it won't resize with the figure.
2: Like dpb mentioned, more complicated layout management can be accomplished with a callback function that executes when the figure is resized. A figure object can be assigned function handle for the 'ResizeFcn' property. You can create a user-defined function which looks at figure and object geometries and manages them accordingly. Then just set it like so:
or if you want to pass extra parameters to the function (e.g. the current figure handle)

Sign in to comment.

Answers (0)




Community Treasure Hunt

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

Start Hunting!