www.gusucode.com > econ 案例源码程序 matlab代码 > econ/ChangeColorandTransparencyofRecessionBandsExample.m
%% Change Color and Transparency of Recession Bands % Overlay recession bands on a plot of multiple time series. Return the % handles of the recession bands so you can change their color and transparency. % Copyright 2015 The MathWorks, Inc. %% % Load data on credit defaults, and extract the predictor variables in the % first four columns. load Data_CreditDefaults X0 = Data(:,1:4); T0 = size(X0,1); %% % Convert dates to serial date numbers, and then plot the four time series. dates = datenum([dates,ones(T0,2)]); figure; plot(dates,X0,'LineWidth',2); h = gca; h.XTick = dates(1:2:end); datetick('x','yyyy','keepticks') xlabel 'Year'; ylabel 'Level'; axis tight %% % Overlay recession bands, returning the handles to the bands. Change the % band color to red and increase the transparency. hBands = recessionplot; set(hBands,'FaceColor','r','FaceAlpha',0.4)