function handles = create_area_plot(handles)
% Get the current settings from the slider bars. This determines which day
% layers and periods will be displayed
cur_day = round(get(handles.scrollDay,'Value'));
cur_layer = round(get(handles.scrollLayer,'Value'));
cur_period = round(get(handles.scrollPeriod,'Value'));
area_data = handles.data.area_data;
% ===============================================================
% Create the Area plot for the Day slice
if ~isfield(handles.data,'h_day_area')
% Select the "DateArea" axes
axes(handles.axDateArea);
% Display the area plot
handles.data.h_day_area = area(area_data(:,:,cur_day));
set(gca,'XTick',[0:4:48]);
% Add a legend
cur_price_bands = num2str(handles.data.price_bands(cur_day,:)');
legend(cur_price_bands,-1);
set(gca,'climmode','manual');
title(handles.data.disp_dates{cur_day})
ylabel('MW')
end
% Set the visibility of the layers in the 3D plot according to the slider
% bar setting
off_list = setdiff( 1:length(handles.data.h_day_area) , 1:cur_layer );
set(handles.data.h_day_area(off_list),'Visible','off');
set(handles.data.h_day_area(1:cur_layer),'Visible','on');
% ===============================================================
% Create the Area plot for the Period slice
if ~isfield(handles.data,'h_period_area')
% Select the "Period Area" axes
axes(handles.axPeriodArea);
% Select the required data
cur_data = area_data(cur_period,:,:);
cur_data = reshape(cur_data,size(cur_data,2),size(cur_data,3))';
% Display the bar charr
handles.data.h_period_area = bar(cur_data,'stacked');
% Add a legend
cur_price_bands = num2str(handles.data.price_bands(cur_day,:)');
legend(cur_price_bands,-1);
% Set the X-axis labels
set(gca,'XTick',1:2:size(area_data,3));
set(gca,'XTickLabel', handles.data.disp_dates(1:2:end));
set(gca,'climmode','manual');
% Set the title
title(['Period = ' num2str(cur_period)])
ylabel('MW')
end
% Set the visibility of the pieces of the bar chart
set(handles.data.h_period_area(off_list),'Visible','off');
set(handles.data.h_period_area(1:cur_layer),'Visible','on');