# Drawing the x-axis at y=0

441 Ansichten (letzte 30 Tage)
David am 4 Nov. 2011
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
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Akzeptierte Antwort

Brian Russell am 30 Apr. 2021
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 KommentareKeine anzeigenKeine ausblenden
Walter Roberson am 1 Mai 2021
xline() and yline() are new as of R2018b; a lot of the other replies are dealing with older releases.
Gehad Qaki am 7 Dez. 2022
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!

Melden Sie sich an, um zu kommentieren.

### Weitere Antworten (4)

Kyle Johnson am 30 Mär. 2023
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 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
Christian Schröder am 18 Jan. 2024
Thanks! This is the correct way to do this in modern MATLAB, and this should be the accepted answer.

Melden Sie sich an, um zu kommentieren.

Amith Kamath am 4 Nov. 2011
You may want to look at this example:
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

Jan am 4 Nov. 2011
Further solutions:
It is always a good idea to search in the FEX.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

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 KommentareKeine anzeigenKeine ausblenden
Bartche am 3 Mär. 2021
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 am 3 Mär. 2021
Bearbeitet: Walter Roberson am 1 Mai 2021

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by