# How to get the x axis and y axis to start at 0 when adding regression line in Figure window

6 views (last 30 days)

Show older comments

Stephnie Watson
on 14 May 2021

Commented: Stephnie Watson
on 14 May 2021

##### 0 Comments

### Accepted Answer

Scott MacKenzie
on 14 May 2021

I'm assuming you don't want to loose the points with y < 0. Something like this should work...

% test data

x = 1:100;

y = linspace(1,60) + randi([-5 5], 1, 100);

p = scatter(x, y, 'filled');

lsline;

ax = gca;

ax.YLim = [-10 70];

ax.XAxisLocation = 'origin';

### More Answers (1)

David Fletcher
on 14 May 2021

Edited: David Fletcher
on 14 May 2021

Does the axis command do anything:

axis([0 70 0 70])

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!