MATLAB Answers

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

71 views (last 30 days)
Junia Josephine D on 27 Feb 2016
Commented: Walter Roberson on 29 Feb 2016
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)

#### 0 Comments

Sign in to comment.

### Answers (1)

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

Show 1 older comment
the cyclist on 28 Feb 2016
Hm. I don't understand why our outputs are different. I can see from the color scheme of our plots that you are using an older version of MATLAB than I am, but I would have expected clipping to behave in the same way.
Sorry, I have no further advice.
Junia Josephine D on 28 Feb 2016
Its okay. Thanks for the reply :)
Walter Roberson on 29 Feb 2016
I am getting the clipped result in R2014a in OS-X.

Sign in to comment.

### Community Treasure Hunt

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

Start Hunting!

Translated by