Reputation: 221
I would like to zoom a particular range in MATLAB subplot.
For example:
xzoom = 1:end;
yzoom = 10;
I want the script to zoom automatically, only the above mentioned ranges.
I have tried this this code:
hZoom = zoom(gcf);
figure;plot(magic(10)); hCMZ = uicontextmenu;
hZMenu = uimenu('Parent',hCMZ,'Label','Switch to pan',...
'Callback','pan(gcbf,''on'')');
hZoom = zoom(gcf);
set(hZoom,'UIContextMenu',hCMZ);
zoom('on').
hZMenu = uimenu('Parent',hCMZ,'Label','Switch to pan',...
'Callback','pan(gcbf,''on'')');
This gives the lens for me to zoom, but I don't want this. I want it to display the zoomed portion automatically. How would I accomplish this?
Upvotes: 0
Views: 2822
Reputation: 2409
You could always just change the axis range manually, like so:
data = magic(10);
xmin = 1;
xmax = size(data, 1);
ymin = 10;
ymax = 10;
hPlot = plot(data);
axis(hPlot, [xmin xmax ymin ymax])
I tried to fit the values of y and x min and max to your question but you can change them as needed.
Upvotes: 1