MATLAB: How to add a background rectangle to figure using figure toolbar

annotation;backgroundinsertMATLABrectangle

How do you add a rectangle to a figure using the toolbar such that the rectangle goes in the background? 
For example, I plot a line using "plot". Then, in the figure, I select 'insert' -> 'rectangle'. How would I move that rectangle to the background, so the line goes over the rectangle rather than the rectangle covering the line?

Best Answer

You cannot place a rectangle in the background using 'insert' -> 'rectangle'. 
Instead, create the rectangle in the command window / script and just add shapes/lines as desired, adding the object you want on top last. For example:
>> figure1 = figure;
>> axes1 = axes('Parent', figure1);
>> hold(axes1,'on');
>> rectangle('Parent',axes1,'Position',[3 3 3 3],'FaceColor',[1 0 0]); % Plots the rectangle
>> plot(1:10); % Plots the line
'Insert' -> 'rectangle' actually creates an annotation in the shape of a rectangle, rather than just a rectangle.