MATLAB Answers


How do I get a zoomed portion of a plot inside a plot, to enhance the visualization?

Asked by Abhinav Sinha on 18 Mar 2018
Latest activity Answered by Junaid Qadir on 7 Mar 2019
Suppose I have a plot, e.g. some function y(x) and I have plotted it. Now, if I wish to zoom a particular portion on the graph and show the zoomed portion inside the same plot (preferably by making a small box), is there any tool to do that with less computation (some GUI, etc.)?


You can use subplot and restrict the axes range of your interest.
No, I do not need a subplot. This needs to be done in the same plot. Something like this, which I have done by creating a box of some dimension and then placing it in a suitable position.

Sign in to comment.

2 Answers

Answer by Ahmet Cecen on 18 Mar 2018
Edited by Ahmet Cecen on 18 Mar 2018

I am giving you the framework that you can use to do this the way you want. Every component of what you asked is there, they are just either placed or formatted differently. Tweaking and formatting is up to you.
r1 = [1:100]'.*rand(100,1);
a1 = axes();
a2 = axes();
a2.Position = [0.3200 0.6600 0.2 0.2]; % xlocation, ylocation, xsize, ysize
plot(a2,r1(50:70)); axis tight
annotation('ellipse',[.2 .3 .2 .2])
annotation('arrow',[.1 .2],[.1 .2])

  1 Comment

Somewhat similar. Anyway, Thanks for your help.

Sign in to comment.

Answer by Junaid Qadir on 7 Mar 2019

How can I zoom the subplot within same plot?


Sign in to comment.