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

조회 수: 5(최근 30일)
How do I edit the graph to get the x and y axis at 0 to line up at 0 instead of the way it is spaced?

채택된 답변

Scott MacKenzie
Scott MacKenzie 2021년 5월 14일
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');
ax = gca;
ax.YLim = [-10 70];
ax.XAxisLocation = 'origin';
  댓글 수: 3

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

추가 답변(1개)

David Fletcher
David Fletcher 2021년 5월 14일
편집: David Fletcher 2021년 5월 14일
Does the axis command do anything:
axis([0 70 0 70])
  댓글 수: 1
Stephnie Watson
Stephnie Watson 2021년 5월 14일
편집: Stephnie Watson 2021년 5월 14일
How would I add the axis code in the Figure window? I don't have any code that I have created. I used create plot then opened the Figures window to add the regression line.

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





Community Treasure Hunt

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

Start Hunting!

Translated by