MATLAB: Drawing X and Y axis on 2D plot

axesplotting

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?

Best Answer

xL = xlim;
yL = ylim;
line([0 0], yL); %x-axis
line(xL, [0 0]); %y-axis
Related Question