www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/CreateSubplotsAndLinkTheirAxesExample.m
%% Create Subplots and Link Their Axes % Create a figure with three subplots and plot data in each subplot. Link % the _x_-axes and _y_-axes for the three subplots. The |linkaxes| function % uses the limits from the first axes passed to it. Panning or zooming into % one of the subplots displays the same range of data in the other two % subplots. figure ax1 = subplot(2,2,1); x1 = linspace(0,6); y1 = sin(x1); plot(x1,y1) ax2 = subplot(2,2,2); x2 = linspace(0,10); y2 = sin(2*x2); plot(x2,y2) ax3 = subplot(2,2,[3,4]); x3 = linspace(0,16); y3 = sin(6*x3); plot(x3,y3) linkaxes([ax1,ax2,ax3],'xy') %% % To remove the linking, use |linkaxes([ax1,ax2,ax3],'off')|.