MATLAB: Link axes of specific subplots

link axis subplot

I have a subplot of size (8,1). I want to link the x-axis of the first two subplots with eachother (so they'll stay the same when zooming), and the 3rd-8th axes of eachother.
Could you help me?

Best Answer

Hi Lieke,
Try this below:
ax1 = subplot(8,1,1);
% plot something


ax2 = subplot(8,1,2);
% plot something
ax8 = subplot(8,1,8);
% plot something
linkaxes([ax1,ax2],'x');
linkaxes([ax3,ax8],'x'); % where ax1 ... ax8 are your axis handles.