The walk around itself is a very simple idea, you can create another axes on top of the original plot and have the zoom-in data copied over to the new axes. If you are doing it for one time only or the plots are very similar, then it may make sense just to hard code everything in and move on. However, in the case where the plots vary quite a bit, a function is probably needed to make it less of a pain.
FUNCTION DESIGN
Input(s):
ah: handle of the existing axes
source_pos: the position of the portion to be zoomed in
target_pos: the position where the zoom-in plot will be placed
* To make the function easy to use, the positions as the input variables are based on the axes in the original plot.
Download the zoomPlot.m file from here here and run the following code to see the function in action.
figure;
t = 0:0.001:0.1;
plot(t, cos(2*pi*50*t));
ah = gca;
% location of the plot to be zoomed in.
s_pos =[0.05 0 0.06 0.1];
% location of the zoom-in plot
t_pos = [0.035 0.4 0.065 0.7];
% generate a zoom-in plot.
zoomPlot(ah, s_pos, t_pos);
The resulting plot will look like
So what has been cover in this post is the basic idea of how to get a zoom-in plot to be on top of the original plot. There are many ways to make this basic function more robust and useful.
- to allow user specify the positions interactively using mouse
- to allow user more flexibility in controlling the appearance of the zoom-in axes.
- etc.