www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/CreateRectangleAnnotationExample.m
%% Create Rectangle Annotation % Create a stem plot and add a rectangle annotation to the figure. Change % the color of the rectangle outline by specifying the |Color| property. % Copyright 2015 The MathWorks, Inc. figure data = [2 4 6 7 8 7 5 2]; stem(data) dim = [.3 .68 .2 .2]; annotation('rectangle',dim,'Color','red') %% % Add a second rectangle annotation to the figure. Specify the fill % color by setting the |FaceColor| property. Add transparency by setting % the |FaceAlpha| property to a value between 0 (completely transparent) % and 1 (completely opaque). dim2 = [.74 .56 .1 .1]; annotation('rectangle',dim2,'FaceColor','blue','FaceAlpha',.2)