zooming a portion in the same figure (MATLAB)
6 次查看(过去 30 天)
显示 更早的评论
Dear members,
I want to know how to zoom a part in MATLAB figures and put it in the same figure as in this example:
0 个评论
采纳的回答
DGM
2022-2-6
编辑:DGM
2022-2-6
Here's a start:
% some simulant data
xr = [0 pi];
x = linspace(xr(1),xr(2),100);
y1 = -cos(x);
y2 = -0.95*cos(0.99*x);
% do the main plots, keep the handles
h(1) = plot(x,y1); hold on
h(2) = plot(x,y2,':');
grid on
xlim(xr)
% create roi box
rrx = [1 1.25]; % roi extents x
rry = [-0.5 -0.4]; % roi extents y
plot(rrx([1 1 2 2 1]),rry([2 1 1 2 2]),'k:') % box
% these lines are just manually positioned so that they avoid the labels
plot([2 rrx(2) rrx(2) 2],[-0.2 rry(2) rry(1) -0.62],'k:')
% add inner axes for roi
hax1 = gca; % save this handle in case it's needed later
hax2 = axes('position',[0.65 0.25 0.2 0.2]);
% the same plot commands, but with different xlim, ylim
plot(x,y1); hold on
plot(x,y2,':')
grid on
xlim(rrx)
ylim(rry)
% explicitly set up legend using only the handles for the first two plots
legend(h,{'thing','other thing'},'location','northwest')
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Exploration 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!