Drawing the x-axis at y=0
302 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
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.
Gehad Qaki
2022-12-7
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 个评论
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Graphics Performance 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!