这与 Try Hard 在评论中建议的内容一致。
以下代码是一个复制/粘贴示例,用于创建类似于您似乎拥有的数据集,绘制它,然后在空白区域中添加一个缩放图:
% generate example data-set
% for the sake of simplicity, the x-data will be ascending
X(1:5,1) = sort(rand(5,1)*0.05+0.1);
X(6:7,1) = sort(rand(2,1)*0.1+0.5);
Y(1:5,1) = rand(5,1)*10+50;
Y(6:7,1) = rand(2,1)*10+90;
Yerr = rand(7,2)*25;
% initial errorbar plot
eax = axes('Position', [0.15, 0.15, 0.75, 0.75]);
errorbar(eax,X,Y,Yerr(:,1),Yerr(:,2),'ob')
hold on
% control axis range
XMIN = min(X)-0.05;
XMAX = max(X)+0.05;
YMIN = min(Y-Yerr(:,1))-10.0;
YMAX = max(Y+Yerr(:,2))+10.0;
xlim([XMIN XMAX]);
ylim([YMIN YMAX]);
% determine max distance between the two groups
% and its location (index)
[MD, IMD] = max(X(2:end)-X(1:end-1))
% set up zoomed plot
% based on know axis limits and location
% the position of the zoomed plot can be
% set up parametrically:
X1 = (X(IMD,1) + MD * 0.1)/(XMAX-XMIN);
Y1 = (YMIN + 10)/(YMAX-YMIN);
DX1 = 0.35;
DX2 = 1.0;
zax = axes('Position', [X1, Y1, DX1, DX1]);
errorbar(zax,X,Y,Yerr(:,1),Yerr(:,2),'ob')
set(zax,'XLim',[XMIN+0.04 X(IMD)+0.01],'Title',text('String','zoomed'))
此代码生成如下图: