To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016
I want to highlight a period in my plot by adding two vertical lines and coloring between them. Any ideas on how to do that?
No products are associated with this question.
Here's one way:
%Plot something plot(1:10)
% Add lines h1 = line([2 2],[1 10]); h2 = line([5 5],[1 10]);
% Set properties of lines set([h1 h2],'Color','k','LineWidth',2)
% Add a patch patch([2 5 5 2],[1 1 10 10],'r')
% The order of the "children" of the plot determines which one appears on top. % I need to flip it here. set(gca,'children',flipud(get(gca,'children')))