Filter löschen
Filter löschen

How to zoomin the figure with data & background?

3 Ansichten (letzte 30 Tage)
Sounghwan Hwang
Sounghwan Hwang am 14 Jun. 2022
Beantwortet: Shubham am 4 Sep. 2023
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 Kommentar
DGM
DGM am 15 Jun. 2022
What version/environment are you using? Also, what method are you using to zoom in on the figure?

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Shubham
Shubham am 4 Sep. 2023
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!!

Kategorien

Mehr zu Visual Exploration finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by