Is it possible to extend a line which is plotted in one subplot to another subplot in same figure

11 views (last 30 days)
I need to extend a line which I plot in subplot(2,1,1) to subplot(2,1,2). I have used hough transform to detect the lines in subplot(2,1,1), with the values of the lines (ie points), I am constructing a line which is needed to be extended to subplot(2,1,2)

Answers (1)

the cyclist
the cyclist on 27 Feb 2016
Edited: the cyclist on 27 Feb 2016

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.
  4 Comments

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!