フィルターのクリア

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 Center および File ExchangeVisual Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by