# Drawing the x-axis at y=0

조회 수: 281 (최근 30일)
David 2011년 11월 4일
댓글: Christian Schröder 2024년 1월 18일
Hello. At least as the default option, MATLAB draws the x-axis at the bottom-most part of the graph. However, I would like to draw it at y=0 as is a common convention. Is it possible in MATLAB? (including the scale on the axis, and replacing the default axis drawn at the bottom)
Thanks, David

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

### 채택된 답변

Brian Russell 2021년 4월 30일
if all you want is dark axes on your plot at x = 0 and y = 0 you just need the commands xline(0) and yline(0). This question is all over MATLAB Central and everybody gives a more complicated solution. Maybe i don't understand the question!
##### 댓글 수: 2없음 표시없음 숨기기
Walter Roberson 2021년 5월 1일
xline() and yline() are new as of R2018b; a lot of the other replies are dealing with older releases.
This is incredible @Brian Russell. Thank you so much for the very simple solution to a very simple problem. I urge everyone to upvote this response so people see it quicker!

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

### 추가 답변 (4개)

Kyle Johnson 2023년 3월 30일
Matlab now has support for this. You can set the property of the axes handle. No tricks of FEX required. :)
ax = gca;
ax.XAxisLocation = "origin";
ax.YAxisLocation = "origin";
##### 댓글 수: 1이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Christian Schröder 2024년 1월 18일
Thanks! This is the correct way to do this in modern MATLAB, and this should be the accepted answer.

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

Amith Kamath 2011년 11월 4일
You may want to look at this example:
##### 댓글 수: 0이전 댓글 -2개 표시이전 댓글 -2개 숨기기

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

Jan 2011년 11월 4일
Further solutions:
It is always a good idea to search in the FEX.
##### 댓글 수: 0이전 댓글 -2개 표시이전 댓글 -2개 숨기기

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

For posterity, this has been fixed in the HG2 Update. Linked below since this thread is currently the top search result on the topic.
##### 댓글 수: 2없음 표시없음 숨기기
Bartche 2021년 3월 3일
The page you were looking for does not exist. Use the search box or browse topics below to find the page you were looking for.
Walter Roberson 2021년 3월 3일
편집: Walter Roberson 2021년 5월 1일

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

### 카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

### Community Treasure Hunt

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

Start Hunting!

Translated by