Updated 9 Dec 2020
setFigDockGroup sets a figure's (or list of figures') docking group container, enabling to dock figures to containers other than the default 'Figures' container (for example, to the 'Editor' group as shown in the screenshot, or to any new user-defined group, or even to another figure's button).
hGroup = setFigDockGroup(hFig, group)
hButton = setFigDockGroup(hFig, hButton)
hFig is an optional handle or list of handles. These are normally figure handles, but not necessarily: the handles' containing figures are automatically inferred and used. If hFig is not supplied, then the current figure handle (gcf) is assumed.
group is either a group name (e.g., 'Editor', 'Figures', 'my group') or a group handle returned from a previous setFigDockGroup function call.
hButton is the handle of a uicontrol pushbutton on another figure. This button would typically be labeled "undock" or have an undocking icon. Note that the docked figure will be minimized to the target hButton - you will NOT be able to see the docked figure's contents in the target figure, only to undock it via the button. Docking into a figure panel will perhaps be added in some future version.
The returned hGroupContainer object allows access to many useful properties and callbacks. Type "get(hGroupContainer)" to see the full list. Note that hGroupContainer may return empty () if the group container is not visible.
See extended help within.
This code heavily relies on undocumented and unsupported Matlab functionality. It works on Matlab 7.4+, but use at your own risk!
This utility does NOT work with uifigures (created using the uifigure function or App Designer) - only with legacy (Java-based) figures.
Bugs and suggestions:
Please send to Yair Altman (altmany at gmail dot com)
Yair Altman (2023). setFigDockGroup (https://www.mathworks.com/matlabcentral/fileexchange/16650-setfigdockgroup), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Inspired: DOCK and UNDOCK figures into groups
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.
Fixes for recent Matlab releases, up to R2020b
Removed annoying warnings about possible future features removal (yes, we know...)
Fixes for Macs
Fix for R2011a
Enabled docking to a figure button (minimized), and undocking back from that figure button.