How to zoomin the figure with data & background?

3 次查看(过去 30 天)
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