필터 지우기
필터 지우기

How to zoomin the figure with data & background?

조회 수: 3 (최근 30일)
Sounghwan Hwang
Sounghwan Hwang 2022년 6월 14일
답변: Shubham 2023년 9월 4일
Hi! I have one question regarding the zoomin of Matlab figure. Here is my code just in case:
x = 1:500;
y = sind(x);
plot(x,y,'linewidth',3)
axis tight;
hold on
I = imread('peppers.png');
h = image(xlim,-ylim,I);
uistack(h,'bottom')
If you run the above code, the below figure is the output.
I want to zoomin some specific areas of this figure with data and background simultaneously. I've tried several times; however, only data (blue line) was zoom-in, but the background doesn't... I want to know how to zoomin the data and the background at the same time. Do you guys have some solution regarding my problem? I need your help!!
  댓글 수: 1
DGM
DGM 2022년 6월 15일
What version/environment are you using? Also, what method are you using to zoom in on the figure?

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

답변 (1개)

Shubham
Shubham 2023년 9월 4일
You can zoom in programmatically by setting the desired range and zooming in using xlim and ylim.
For example:
x = 1:500;
y = sind(x);
plot(x,y,'linewidth',3)
axis tight;
hold on
I = imread('peppers.png');
h = image(xlim,-ylim,I);
uistack(h,'bottom')
% Set the desired zoomed-in range
x_zoom = [250, 300];
y_zoom = [-1, -0.8];
% Zoom in on the plot
xlim(x_zoom)
ylim(y_zoom)
The above code produces the following output:
In the above image, the plot is zoomed in along with the background image. Similarly, you can zoom in and out by setting the limits to zoom in on your desired points.
Hope this helps!!

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by