MATLAB: Do lines on the edges of the axes not always appear correctly in MATLAB 7.10 (R2010a)

MATLAB

I am drawing lines of the edges of the axes in my figure:
line([axlims(2) axlims(2)],[axlims(3) axlims(4)],'color','r','Clipping','off'); %draws line on right y-axis
h = line([axlims(1) axlims(2)],[axlims(4) axlims(4)],'color','r','Clipping','off'); %draws line on top x-axis
I notice that they do not always appear correctly.

Best Answer

In general, drawing the lines at the edge of the axes has the danger of getting getting clipped out.
To control clipping you can turn the 'Clipping' to 'off' as follows:
line([axlims(2) axlims(2)],[axlims(3) axlims(4)],'color','r','Clipping','off'); %draws line on right y-axis
h = line([axlims(1) axlims(2)],[axlims(4) axlims(4)],'color','r','Clipping','off'); %draws line on top x-axis
By default objects are created with 'Clipping' set to 'on'.