Partial Zoom in subplot function

조회 수: 18 (최근 30일)
Di Liu
Di Liu 2021년 1월 6일
편집: Adam Danz 2021년 1월 6일
Hi,
I am trying to zoom one part in the subplot figure. For example, I want to zoom one part of the subplot(2,2,1). I use the axes 'axes('position',[0.3 0.2 0.4 0.4])' function, but it will create a zoom part for the whole figure, rather than zooming the defined subplot. Does anyone know how to zoom the defined area in subplot?
Thanks,
Best regards,
Di

채택된 답변

Adam Danz
Adam Danz 2021년 1월 6일
편집: Adam Danz 2021년 1월 6일
axes('position', ...) does not zoom into the axes. It sets the position of the axes relative to the figure.
To zoom into a section of the axes you need to change the xlim and ylim properties. Also set the data aspect ratio (daspect) if you want to maintain the aspect ratio of the data when zooming.
x = rand(1,200);
y = rand(1,200);
figure()
subplot(2,1,1)
hold on
scatter(x,y)
rectangle('Position',[.6 .2 .2 .4],'EdgeColor','r', 'LineWidth',2)
daspect([1,1,1])
title('full data')
subplot(2,1,2)
hold on
scatter(x,y)
xlim([.6 .8])
ylim([.2 .6])
rectangle('Position',[.6 .2 .2 .4],'EdgeColor','r', 'LineWidth',2)
daspect([1,1,1])
title('zoomed')
Related threads on magnified axes:
  댓글 수: 2
Adam Danz
Adam Danz 2021년 1월 6일
Di Liu's answer moved here as a comment
Hi Adam,
Thank you for your help. But can I plot the zoomed part into the subplot figure?Do you know how to do this?
Thanks,
Di
Adam Danz
Adam Danz 2021년 1월 6일
편집: Adam Danz 2021년 1월 6일
I don't understand what you're asking, "...into the subplot figure". My answer has 2 subplots just for demonstration purposes. The 2nd subplot contains the solution.
The two links at the bottom of my answer might be what you're looking for.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by