# How to set y-axes intercept

조회 수: 23 (최근 30일)
Karl 2013년 10월 24일
댓글: Karl 2013년 10월 25일
How do you make the y-axis cross the x-axsis at observation 1 and not 0? Sometimes it happends automatically, sometimes not. Try the code below. The two figures has different axes intercept.
A = rand(15,1);
plot(p1990K1BPreg(1:10, 1))
plot(p1990K1BPreg(1:15, 1))
How do you make the y-axex always intercepting at x=1, as in figure 1 above?

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

### 채택된 답변

Jonathan LeSage 2013년 10월 24일
You can set the limits of the x-axis directly using the xlim function. If you're plotting (x,y) data, you can easily just set the lower x-limit equivalent to your first data point. Here is a little example to help get you started:
% Generate arbitrary data and plot
numPoints = 15;
x = 1:numPoints;
A = rand(numPoints,1);
plot(x,A)
% Get current x-limits
currentLimits = xlim;
% Set x-limits to ensure graph starts at first data point
xlim([x(1) currentLimits(2)]);
As you can see, the xlim function can be used to both get information on the current axes and to set limits. Hope this helps!
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Karl 2013년 10월 25일
It did! Thanks!

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

### 카테고리

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

### Community Treasure Hunt

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

Start Hunting!

Translated by