MATLAB 图中放大图

magnifyOnFigure是一个工具箱,下载链接为:https://download.csdn.net/download/miao0967020148/15154799?spm=1001.2014.3001.5501

clc;
clear all
close all
disp( sprintf('The figure handle is here passed as an input argument.') ) 
fig = figure;
hold on;
plot(rand(100,1), 'b'); plot(rand(300, 1), 'r'); 
grid on;
hold off;
magnifyOnFigure(fig);
disp('Press a key...')
pause;

img

 magnifyOnFigure(fig,'displayLinkStyle', 'straight',...
                    'EdgeColor', 'black',...
                    'magnifierShape', 'rectangle',...
                    'initialPositionSecondaryAxes', [80 150 96 56],...
                    'initialPositionMagnifier',     [150 100 24 16],...    
                    'frozenZoomAspectratio', 'on',...
                    'edgeWidth',1); 

'initialPositionSecondaryAxes', [80 150 96 56] 设置放大图的位置

'initialPositionMagnifier', [150 100 24 16]设置放大的区域

img