If I have a plot containing a line, I would like to add a patch but have it appear under the line so the line remains visible. (Not possible to plot the patch first in my real application). How can I do this using the example below?
figure;h = plot(rand(1,10), rand(1,10)); % Make a line plot
hold on;% Get coordinates for a patch in the lower quarter of the figure
xd = get(gca, 'xlim'); xd = [xd(1) xd(2)/2];yd = get(gca, 'ylim'); yd = [yd(1) yd(2)/2];x = [xd(1) xd(2) xd(2) xd(1) xd(1)];y = [yd(1) yd(1) yd(2) yd(2) yd(1)];% The following patch lies over the line
p = patch(x, y, 'g');
Best Answer