recipes : Plotting : Line and Scatter Plots : How do I plot objects outside of the axes?

Problem

How do I plot objects, such as lines or points, outside of the axes?

Solution

Set the clipping property to off. Example:

clf
x= -10*pi : 0.5 : 10*pi;
y= sin(x);

inside=plot(x,y+x,'-r');
hold on
outside=plot(x,y,'-*b');
hold off

%Now set the axis limits
xlim([min(x),max(x)])
ylim([0,30])
set(gca,'XTickLabel',[])

%Now make blue points visible outside the axes
set(outside,'Clipping','off')

If the above fails to work, then close your figure window and repeat the process in a new window.