Drawing X and Y axis on 2D plot
Ältere Kommentare anzeigen
Hi everyone,
I have been searching for an easy way to draw the x and y axis on a plot but cannot seem to do it. For example, if I have a plot that has range [-2 10] for x and [-200 400] for y, I would like to be able to draw a line along x = 0 and y = 0. I have looked at certain functions such as axescenter but this draws the axes in the exact center so it does not work for me. The style is great but I can't get it along the axes. Anyone have any ideas?
Akzeptierte Antwort
Weitere Antworten (3)
Brian Russell
am 30 Apr. 2021
25 Stimmen
Why does everyone give such complicated answers to this question? The answer is xline(0) and yline(0).
4 Kommentare
Elie Marouani
am 18 Mai 2021
Bearbeitet: Elie Marouani
am 18 Mai 2021
This is exactly what i needed here, thank you
Sajib Biswas Shuvo
am 21 Jun. 2021
This answer should be at the top. Thanks btw.
Brian Russell
am 21 Jun. 2021
Thanks, Sajib, but I don't know how to move it to the top. I think an administrator has to do that. I think that in an earlier version of MATLAB, the answer at the top was the correct one, but the answer I gave must be a new feature.
Alex Henderson
am 23 Feb. 2023
"Why does everyone give such complicated answers to this question?"
Probably because these functions only appeared in R2018b. Still, useful to know they're there now.
Steven Lord
am 1 Sep. 2016
5 Stimmen
As of release R2015b you can set the axes XAxisLocation and YAxisLocation properties to 'origin' to get the axes lines to cross at the origin.
1 Kommentar
Kajeen Hassan
am 28 Jan. 2020
0 Stimmen
A parametric equation to plot the function x= 1.5 sin(5t), y= 1.5 cos(3t) , plot the function for 0<=t<=2* pi. Format the plot such that the both axes will range from -2 to 2.
Kategorien
Mehr zu Annotations finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!