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

조회 수: 6 (최근 30일)
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)

답변 (1개)

the cyclist
the cyclist 2016년 2월 27일
편집: the cyclist 2016년 2월 27일

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

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by