Updated 28 Mar 2010
This utility provides a powerful zooming tool specially designed for the documentation of original and zoomed 2D graphics of images on the same plot.
It is composed of two blocks (the secondary axes and the magnifier). The secondary axes, which can be arbitrarily allocated within the limits of the figure, displays the area marked by the magnifier.
The highly versatile interface of the 'on-figure magnifier' offers a world of possibilities in a broad range of applications and fields. The Keyboard/mouse or programmatic configuration of this tool allows the user to set her or his own graphic style, to suit the requirements of any publication's editor. More details on interfacing and properties can be found in the .m file.
EXAMPLE: (for usage examples, run 'magnifyOnFigure_examples.m')
'edgeWidth' Color of the box surrounding the secondary
axes, magnifier and link. Default 1
'edgeColor': Color of the box surrounding the secondary
axes, magnifier and link. Default 'black'
'displayLinkStyle': Style of the link. 'none', 'straight' or
'edges', with 'straight' as default.
'mode': 'manual' or 'interactive' (allowing
adjustments through mouse/keyboard). Default
'units' Units in which the position vectors are
given. Only 'pixels' currently supported
'initialPositionSecondaryAxes': Initial position vector ([left bottom width height])
of secondary axes, in pixels
'initialPositionMagnifier': Initial position vector ([left bottom width height])
of magnifier, in pixels
'secondaryAxesXLim': Initial XLim value of the secondary axes
'secondaryAxesYLim': Initial YLim value of the secondary axes
HOT KEYS (active if 'mode' set to 'interactive')
-In a figure with multiple magnigier instances
'Tab': Switch the focus from one magnifier instance
to the next one on the current figure.
'Mouse pointer on secondary axes or magnifier of a tool+double left click'
-On the focused magnifier instance
'up arrow': Moves magnifier 1 pixel upwards
'down arrow': Moves magnifier 1 pixel downwards
'left arrow': Moves magnifier 1 pixel to the left
'right arrow': Moves magnifier 1 pixel to the right
'Shift+up arrow': Expands magnifier 10% on the Y-axis
'Shift+down arrow': Compress magnifier 10% on the -axis
'Shift+left arrow': Compress magnifier 10% on the X-axis
'Shift+right arrow': Expands magnifier 10% on the X-axis
'Control+up arrow': Moves secondary axes 1 pixel upwards
'Control+down arrow': Moves secondary axes 1 pixel downwards
'Control+left arrow': Moves secondary axes 1 pixel to the left
'Control+right arrow': Moves secondary axes 1 pixel to the right
'Alt+up arrow': Expands secondary axes 10% on the Y-axis
'Alt+down arrow': Compress secondary axes 10% on the Y-axis
'Alt+left arrow': Compress secondary axes 10% on the X-axis
'Alt+right arrow': Expands secondary axes 10% on the X-axis
'PageUp': Increase additional zooming factor on X-axis
'PageDown': Decrease additional zooming factor on X-axis
'Shift+PageUp': Increase additional zooming factor on Y-axis
'Shift+PageDown': Decrease additional zooming factor on Y-axis
'Control+Q': Resets the additional zooming factors to 0
'Control+A': Displays position of secondary axes and
magnifier in the command window
'Control+D': Deletes the focused tool
'Mouse pointer on magnifier+left click' Drag magnifier to any
'Mouse pointer on secondary axes+left click' Drag secondary axes in any
David Fernandez-Prim (2023). On-figure magnifier (https://www.mathworks.com/matlabcentral/fileexchange/26007-on-figure-magnifier), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Inspired by: ZoomBox, magnify, magnifyrecttofig, Jeweler's Loupe
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.
Tool identification feature added. Now, 'Control+I' shows/hides the tool identifier (red background color when the tool has the focus, black otherwise)
Improved help documentation
Solved bug when resizing the host figure
Added 'delete' functionality.
Solved bug when the contents of the target axes are other than 'line' or 'image'
Solved bug when axis mode is set to other than 'normal'.
Solved bug appearing when any of the axes are reversed. It also works on images now.
Added possibility to select target axes in a multiaxes figure
Solved bug when 'displayLinkStyle' is set to 'edges'