Skip to Main Content Skip to Search
Accelerating the pace of engineering and science

How do I zoom on multiple axes at once in MATLAB 6.0 (R12)?


Date Last Modified: Wednesday, January 20, 2010
Solution ID:   1-15WA9
Product:   MATLAB
Reported in Release:   R12
Platform:   All Platforms
Operating System:   All OS
 

Subject:

How do I zoom on multiple axes at once in MATLAB 6.0 (R12)?

Problem Description:

I am aware of the function PLOTYY for creating multiple y axes on a figure. However, the ZOOM function only zooms on one axis.

I would like to zoom into two axis at the same time and zoom factor.

Solution:

This enhancement has been incorporated in MATLAB 7.5 (R2007b).

To work around this issue in previous MATLAB releases, if you are using MATLAB 7.0 (R14) or later, you can use SUBPLOT instead of PLOTYY with LINKAXES to synchronize the limits of multiple axes. An example code of this method is shown below:
ax(1) = subplot(2,2,1);
plot(rand(1,10)*10,'Parent',ax(1));
ax(2) = subplot(2,2,2);
plot(rand(1,10)*100,'Parent',ax(2));
linkaxes(ax,'x');
For more information, please see the documentation for LINKAXES by executing the following in the MATLAB Prompt:
web([docroot,'/techdoc/ref/linkaxes.html'])

If you are using a version of MATLAB prior to 7.0 (R14), you can try using the customer contributed MATLAB function "linkedzoom.m". You can download this from the MATLAB Central File Exchange at the following URL:

http://www.mathworks.com/matlabcentral/fileexchange/loadFile.do?objectId=1037&objectType=file

NOTE: This code has not been officially tested with MATLAB, and is therefore not officially supported by MathWorks, Inc.

Please provide feedback to help us improve this Solution
Contact support