Yes. You just need to turn off "clipping". Here is an example:
rng 'default'
figure
subplot(2,1,1), plot(rand(3,4).'.') subplot(2,1,2), plot(rand(3,4).'.')
set(gca,'Clipping','Off') h = line([1.4 2.6],[0.4 1.8]); ylim([0 1]) set(h,'LineWidth',2)
A few things to note:
- The line is plotted (in this example) in the coordinate system of the bottom subplot, because that is current axes when I create the line.
- You can't specify the line with coordinates from both sets of axes (I believe)
- I had to specify the ylim of the bottom subplot, so that it would not just automatically resize to accommodate the line.