필터 지우기
필터 지우기

zooming a portion in the same figure (MATLAB)

조회 수: 2 (최근 30일)
high speed
high speed 2022년 2월 6일
편집: DGM 2022년 2월 6일
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:

채택된 답변

DGM
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개)

카테고리

Help CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by