diff --git a/ScriptsDataset/analyze_dataset.m b/ScriptsDataset/analyze_dataset.m index c8a6c69..96cffce 100644 --- a/ScriptsDataset/analyze_dataset.m +++ b/ScriptsDataset/analyze_dataset.m @@ -88,11 +88,9 @@ function plot_boxes(ds,target,id) set(ax,'XTick',1:n,'XTickLabels',ds.FirmNames,'XTickLabelRotation',45); set(ax,'YLim',[y_low y_high]); - figure_title(target); + figure_title(f,target); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -163,18 +161,14 @@ function plot_crises(ds,id) end if (strcmp(ds.CrisesType,'E')) - figure_title('Crises (Events)'); + figure_title(f,'Crises (Events)'); else - figure_title('Crises (Ranges)'); + figure_title(f,'Crises (Ranges)'); end - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); if (~isempty(tooltips)) - drawnow(); - dcm = datacursormode(f); set(dcm,'Enable','on','SnapToDataVertex','off','UpdateFcn',@(targ,evtd)create_tooltip(targ,evtd,tooltips)); createDatatip(dcm,tooltips_target,[1 1]); @@ -243,7 +237,7 @@ function plot_index(ds,id) t2_position = get(t2,'Position'); set(t2,'Position',[0.4783 t2_position(2) t2_position(3)]); - t = figure_title(['Index (' ds.IndexName ')']); + t = figure_title(f,['Index (' ds.IndexName ')']); t_position = get(t,'Position'); set(t,'Position',[t_position(1) -0.0157 t_position(3)]); @@ -276,9 +270,7 @@ function plot_index(ds,id) annotation('TextBox',(get(sub_2,'Position') + [0.01 -0.025 0 0]),'String',txt,'EdgeColor','none','FitBoxToText','on','FontSize',8); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -319,11 +311,9 @@ function plot_risk_free_rate(ds,id) date_ticks([sub_1 sub_2],'x','yyyy','KeepLimits'); end - figure_title('Risk-Free Rate'); + figure_title(f,'Risk-Free Rate'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -402,25 +392,27 @@ function plot_function(subs,data) delete(findall(gcf,'type','annotation')); - plot(subs(1),x,y,'Color',[0.000 0.447 0.741]); - set(subs(1),'YLim',[(y_min - 0.01) (y_max + 0.01)]); + sub_1 = subs(1); + plot(sub_1,x,y,'Color',[0.000 0.447 0.741]); + set(sub_1,'YLim',[(y_min - 0.01) (y_max + 0.01)]); if (~isempty(xd)) - hold(subs(1),'on'); - plot(subs(1),[xd xd],get(subs(1),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,[xd xd],get(sub_1,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); end - hist = histogram(subs(2),y,50,'FaceColor',[0.749 0.862 0.933],'Normalization','pdf'); + sub_2 = subs(2); + hist = histogram(sub_2,y,50,'FaceColor',[0.749 0.862 0.933],'Normalization','pdf'); edges = get(hist,'BinEdges'); edges_max = max(edges); edges_min = min(edges); [dv,dp] = ksdensity(y); - hold(subs(2),'on'); - plot(subs(2),dp,dv,'-b','LineWidth',1.5); - hold(subs(2),'off'); - set(subs(2),'XLim',[(edges_min - (edges_min * 0.1)) (edges_max - (edges_max * 0.1))]); + hold(sub_2,'on'); + plot(sub_2,dp,dv,'-b','LineWidth',1.5); + hold(sub_2,'off'); + set(sub_2,'XLim',[(edges_min - (edges_min * 0.1)) (edges_max - (edges_max * 0.1))]); txt_obs = sprintf('Observations: %d',y_obs); txt_avg = sprintf('Mean: %.4f',y_avg); @@ -449,7 +441,7 @@ function plot_function(subs,data) txt = {txt_obs '' txt_avg txt_med txt_std txt_ske txt_kur '' txt_s txt_lbq txt_a}; - annotation('TextBox',(get(subs(2),'Position') + [0.01 -0.025 0 0]),'String',txt,'EdgeColor','none','FitBoxToText','on','FontSize',8); + annotation('TextBox',(get(sub_2,'Position') + [0.01 -0.025 0 0]),'String',txt,'EdgeColor','none','FitBoxToText','on','FontSize',8); end @@ -513,12 +505,13 @@ function plot_function(subs,data) xd = x(d) - 1; end - plot(subs(1),x,y,'Color',[0.000 0.447 0.741]); + sub_1 = subs(1); + plot(sub_1,x,y,'Color',[0.000 0.447 0.741]); if (~isempty(xd)) - hold(subs(1),'on'); - plot(subs(1),[xd xd],get(subs(1),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,[xd xd],get(sub_1,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); end end diff --git a/ScriptsMeasures/run_bubbles_detection.m b/ScriptsMeasures/run_bubbles_detection.m index d73ff76..64cea0f 100644 --- a/ScriptsMeasures/run_bubbles_detection.m +++ b/ScriptsMeasures/run_bubbles_detection.m @@ -90,12 +90,11 @@ break; end - - offset = min([(ds.Defaults(i) - 1) (ds.Insolvencies(i) - 1) t]); + offset = min(ds.Defaults(i) - 1,t); p_i = p(1:offset,i); [bsadfs,cvs,detection,breakdown] = psy_bubbles_detection(p_i,ds.CVM,ds.CVQ,ds.LagMax,ds.LagSel,ds.MBD); - ds.BSADF(1:offset,i) = bsadfs; + ds.BSADFS(1:offset,i) = bsadfs; ds.CVS(1:offset,i) = cvs; ds.BUB(1:offset,i) = detection(:,1); ds.BMPH(1:offset,i) = detection(:,2); @@ -187,7 +186,7 @@ ds.LabelsSheetsSimple = [ds.LabelsMeasuresSimple {'Indicators'}]; ds.LabelsSheets = [ds.LabelsMeasures {'Indicators'}]; - ds.BSADF = NaN(t,n); + ds.BSADFS = NaN(t,n); ds.CVS = NaN(t,n); ds.BUB = NaN(t,n); ds.BMPH = NaN(t,n); @@ -202,7 +201,7 @@ function ds = finalize(ds) - bc = sum(ds.Bubbles .* ds.Capitalizations,2,'omitnan'); + bc = sum(ds.BUB .* ds.Capitalizations,2,'omitnan'); bcp = bc ./ sum(ds.Capitalizations,2,'omitnan'); ds.Indicators = [bc bcp]; @@ -262,6 +261,202 @@ function write_results(ds,temp,out) function analyze_result(ds) + safe_plot(@(id)plot_sequence(ds,id)); + safe_plot(@(id)plot_indicators(ds,id)); + +end + +function plot_indicators(ds,id) + + bc = ds.Indicators(:,1); + bcp = ds.Indicators(:,2); + + y_limits_bc = plot_limits(bc,0.1,0); + y_limits_bcp = [0 100]; + + f = figure('Name','Bubbles Detection Measures > Indicators','Units','normalized','Position',[100 100 0.85 0.85],'Tag',id); + + sub_1 = subplot(2,1,1); + plot(sub_1,ds.DatesNum,smooth_data(bc),'Color',[0.000 0.447 0.741]); + set(sub_1,'YLim',y_limits_bc); + t1 = title(sub_1,ds.LabelsIndicators{1}); + set(t1,'Units','normalized'); + t1_position = get(t1,'Position'); + set(t1,'Position',[0.4783 t1_position(2) t1_position(3)]); + + sub_2 = subplot(2,1,2); + area(sub_2,ds.DatesNum,smooth_data(bcp),'EdgeColor',[0.000 0.447 0.741],'FaceAlpha',0.5,'FaceColor',[0.749 0.862 0.933]); + set(sub_2,'YLim',y_limits_bcp); + t2 = title(sub_2,ds.LabelsIndicators{2}); + set(t2,'Units','normalized'); + t2_position = get(t2,'Position'); + set(t2,'Position',[0.4783 t2_position(2) t2_position(3)]); + + set([sub_1 sub_2],'XLim',[ds.DatesNum(1) ds.DatesNum(end)],'XTickLabelRotation',45); + set([sub_1 sub_2],'XGrid','on','YGrid','on'); + + if (ds.MonthlyTicks) + date_ticks([sub_1 sub_2],'x','mm/yyyy','KeepLimits','KeepTicks'); + else + date_ticks([sub_1 sub_2],'x','yyyy','KeepLimits'); + end + + figure_title(f,'Indicators'); + + maximize_figure(f); + +end + +function plot_sequence(ds,id) + + n = ds.N; + t = ds.T; + dn = ds.DatesNum; + mt = ds.MonthlyTicks; + + bmph = ds.BMPH; + brph = ds.BRPH; + + data_bsadfs = ds.BSADFS; + data_cvs = ds.CVS; + data_ps = smooth_data(ds.Prices); + data_ps_bm = data_ps .* bmph; + data_ps_br = data_ps .* brph; + data_ps_ot = NaN(t,n); + + data_bds = cell(1,n); + + for i = 1:n + offset = min(ds.Defaults(i) - 1,t); + + bsadfs_i = data_bsadfs(1:offset,i); + idx = find(bsadfs_i ~= 0,1,'first'); + data_bsadfs(1:idx,i) = bsadfs_i(idx + 1); + data_bsadfs(1:offset,i) = smooth_data(data_bsadfs(1:offset,i)); + + cvs_i = data_cvs(1:offset,i); + idx = find(isnan(cvs_i),1,'last'); + data_cvs(1:idx,i) = cvs_i(idx + 1); + data_cvs(1:offset,i) = smooth_data(data_cvs(1:offset,i)); + + data_ps_ot(1:offset,i) = data_ps(1:offset,i) .* ~(bmph(1:offset,i) | bmph(1:offset,i)); + + bd_i = ds.Breakdowns{i}; + + bm_count = sum(bd_i(:,5)); + br_count = sum(bd_i(:,6)); + ot_count = t - (bm_count + br_count); + data_bds{i} = [ot_count bm_count br_count]; + end + + data_ones = ones(1,n); + data = [repmat({dn},1,n); mat2cell(data_bsadfs,t,data_ones); mat2cell(data_cvs,t,data_ones); mat2cell(data_ps,t,data_ones); mat2cell(data_ps_bm,t,data_ones); mat2cell(data_ps_br,t,data_ones); mat2cell(data_ps_ot,t,data_ones); data_bds]; + + plots_title = [repmat({'Bubbles'},1,n); repmat({'Model'},1,n); repmat({'Breakdown - Percentage'},1,n); repmat({'Breakdown - Count'},1,n)]; + + x_limits = [dn(1) dn(end)]; + + core = struct(); + + core.N = n; + core.Data = data; + core.Function = @(subs,data)plot_function(subs,data); + + core.OuterTitle = 'Bubbles Detection Measures > Time Series'; + core.InnerTitle = 'Time Series'; + core.SequenceTitles = ds.FirmNames; + + core.PlotsAllocation = [7 4]; + core.PlotsSpan = {[1:3 5:7 9:11 13:15] [21:23 25:27] [4 8 12] [20 24 28]}; + core.PlotsTitle = plots_title; + + core.XDates = {mt mt [] []}; + core.XGrid = {true true false false}; + core.XLabel = {[] [] [] []}; + core.XLimits = {x_limits x_limits [] []}; + core.XRotation = {45 45 [] []}; + core.XTick = {[] [] [] []}; + core.XTickLabels = {[] [] [] []}; + + core.YGrid = {true true false true}; + core.YLabel = {[] [] [] []}; + core.YLimits = {[] [] [] []}; + core.YRotation = {[] [] [] []}; + core.YTick = {[] [] [] []}; + core.YTickLabels = {[] [] [] []}; + + sequential_plot(core,id); + + function plot_function(subs,data) + + x = data{1}; + bsadfs = data{2}; + cvs = data{3}; + ps = data{4}; + ps_bm = data{5}; + ps_br = data{6}; + ps_ot = data{7}; + bd = data{8}; + + d = find(isnan(ps),1,'first'); + + if (isempty(d)) + xd = []; + else + xd = x(d) - 1; + end + + sub_1 = subs(1); + a1 = area(sub_1,x,ps_ot,'EdgeColor','none','FaceAlpha',0.5,'FaceColor',[0.749 0.862 0.933]); + hold(sub_1,'on'); + a2 = area(sub_1,x,ps_bm,'EdgeColor','none','FaceColor',[0.200 0.627, 0.173]); + a3 = area(sub_1,x,ps_br,'EdgeColor','none','FaceColor',[0.984 0.502 0.447]); + plot(sub_1,x,ps,'Color',[0.000 0.000 0.000]) + hold(sub_1,'off'); + + if (~isempty(xd)) + hold(sub_1,'on'); + plot(sub_1,[xd xd],get(sub_1,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); + end + + l = legend(sub_1,[a1 a2 a3],'None','Boom Phase','Burst Phase','Location','south','Orientation','horizontal'); + set(l,'Units','normalized'); + l_position = get(l,'Position'); + set(l,'Position',[l_position(1) 0.3645 l_position(3) l_position(4)]); + + sub_2 = subs(2); + p1 = plot(sub_2,x,bsadfs,'Color',[0.000 0.447 0.741]); + hold(sub_2,'on'); + p2 = plot(sub_2,x,cvs,'Color',[0.000 0.000 0.000],'LineStyle','--'); + hold(sub_2,'off'); + + if (~isempty(xd)) + hold(sub_2,'on'); + plot(sub_2,[xd xd],get(sub_2,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_2,'off'); + end + + legend(sub_2,[p1 p2],'BSADF','Critical Values','Location','northwest'); + + sub_3 = subs(3); + pc1 = pie(sub_3,bd); + hpc1 = findobj(pc1,'Type','patch'); + set(hpc1(1),'FaceAlpha',0.5,'FaceColor',[0.749 0.862 0.933]); + set(hpc1(2),'FaceColor',[0.200 0.627, 0.173]); + set(hpc1(3),'FaceColor',[0.984 0.502 0.447]); + + sub_4 = subs(4); + b1 = bar(sub_4,1,bd(1)); + set(b1,'FaceAlpha',0.5,'FaceColor',[0.749 0.862 0.933]); + hold(sub_4,'on'); + b2 = bar(sub_4,2,bd(2)); + set(b2,'FaceColor',[0.200 0.627, 0.173]); + b3 = bar(sub_4,3,bd(3)); + set(b3,'FaceColor',[0.984 0.502 0.447]); + hold(sub_4,'off'); + + end end diff --git a/ScriptsMeasures/run_comparison.m b/ScriptsMeasures/run_comparison.m index 8ba8e99..35a51bf 100644 --- a/ScriptsMeasures/run_comparison.m +++ b/ScriptsMeasures/run_comparison.m @@ -698,24 +698,26 @@ function plot_function(subs,data,ct,c1,c2) x = data{1}; y = data{2}; + + sub_1 = subs(1); if (isempty(ct)) - plot(subs(1),x,y,'Color',[0.000 0.447 0.741]); + plot(sub_1,x,y,'Color',[0.000 0.447 0.741]); else if (strcmp(ct,'E')) - plot(subs(1),x,y,'Color',[0.000 0.447 0.741]); + plot(sub_1,x,y,'Color',[0.000 0.447 0.741]); - hold(subs(1),'on'); + hold(sub_1,'on'); for i = 1:numel(c1) - line(subs(1),ones(2,1) .* c1(i),[c2(1) c2(2)],'Color',[1.000 0.400 0.400]); + line(sub_1,ones(2,1) .* c1(i),[c2(1) c2(2)],'Color',[1.000 0.400 0.400]); end - hold(subs(1),'off'); + hold(sub_1,'off'); else - area(subs(1),x,c1,c2,'EdgeColor','none','FaceAlpha',0.4,'FaceColor',[0.850 0.325 0.098]); + area(sub_1,x,c1,c2,'EdgeColor','none','FaceAlpha',0.4,'FaceColor',[0.850 0.325 0.098]); - hold(subs(1),'on'); - plot(subs(1),x,y,'Color',[0.000 0.447 0.741]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,x,y,'Color',[0.000 0.447 0.741]); + hold(sub_1,'off'); end end @@ -758,11 +760,9 @@ function plot_similarity(ds,target,id) set(ax,'XAxisLocation','bottom','XTick',off,'XTickLabels',labels,'XTickLabelRotation',45); set(ax,'YDir','reverse','YTick',off,'YTickLabels',labels,'YTickLabelRotation',45); - figure_title(target); + figure_title(f,target); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -805,13 +805,9 @@ function plot_scores_gc(ds,id) set(sub_2,'Box','on','XGrid','on','YGrid','on'); title('Data Browser'); - figure_title(['Granger-causality (A=' num2str(ds.GCA * 100) '%, LM=' num2str(ds.LagMax) ', LS=' ds.LagSel ')']); + figure_title(f,['Granger-causality (A=' num2str(ds.GCA * 100) '%, LM=' num2str(ds.LagMax) ', LS=' ds.LagSel ')']); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); - - drawnow(); + maximize_figure(f); dcm = datacursormode(f); set(dcm,'Enable','on','SnapToDataVertex','off','UpdateFcn',@(targ,evtd)create_tooltip(targ,evtd,s,data_labels,data)); @@ -867,13 +863,9 @@ function plot_scores_lm(ds,id) set(ax,'XLim',[0 (mn + 1)],'XTick',seq,'XTickLabel',labels,'XTickLabelRotation',45); set(ax,'YGrid','on','YLim',[0 100]); - figure_title(['Logistic Model (ADJ=' lma_label ')']); - - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + figure_title(f,['Logistic Model (ADJ=' lma_label ')']); - drawnow(); + maximize_figure(f); dcm = datacursormode(f); set(dcm,'Enable','on','UpdateFcn',@(targ,evtd)create_tooltip(targ,evtd,mfr2)); @@ -909,13 +901,9 @@ function plot_scores_pps(ds,id) set(ax,'XLim',[0 (mn + 1)],'XTick',seq,'XTickLabel',labels,'XTickLabelRotation',45); set(ax,'YGrid','on','YLim',[0 100]); - figure_title(['Predictive Power Score Model (K=' num2str(ds.PPSK) ')']); - - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + figure_title(f,['Predictive Power Score Model (K=' num2str(ds.PPSK) ')']); - drawnow(); + maximize_figure(f); dcm = datacursormode(f); set(dcm,'Enable','on','UpdateFcn',@(targ,evtd)create_tooltip(targ,evtd,pps)); @@ -969,13 +957,9 @@ function plot_scores_pd(ds,id) set(sub_2,'Box','on','XGrid','on','YGrid','on'); title('Data Browser'); - figure_title(['Price Discovery (' ds.PDT ', LM=' num2str(ds.LagMax) ', LS=' ds.LagSel ')']); + figure_title(f,['Price Discovery (' ds.PDT ', LM=' num2str(ds.LagMax) ', LS=' ds.LagSel ')']); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); - - drawnow(); + maximize_figure(f); dcm = datacursormode(f); set(dcm,'Enable','on','SnapToDataVertex','off','UpdateFcn',@(targ,evtd)create_tooltip(targ,evtd,s,data_labels,data)); @@ -1048,13 +1032,9 @@ function plot_scores_overall(ds,id) set(ax,'XLim',[0 (mn + 1)],'XTick',seq,'XTickLabel',labels,'XTickLabelRotation',45); set(ax,'YGrid','on','YLim',[0 100]); - figure_title('Overall Scores'); - - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + figure_title(f,'Overall Scores'); - drawnow(); + maximize_figure(f); dcm = datacursormode(f); set(dcm,'Enable','on','UpdateFcn',@(targ,evtd)create_tooltip(targ,evtd,ctooltips)); diff --git a/ScriptsMeasures/run_component.m b/ScriptsMeasures/run_component.m index a31df1a..c035476 100644 --- a/ScriptsMeasures/run_component.m +++ b/ScriptsMeasures/run_component.m @@ -381,11 +381,9 @@ function plot_catfin(ds,id) date_ticks(subs,'x','yyyy','KeepLimits'); end - figure_title('CATFIN'); + figure_title(f,'CATFIN'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -468,11 +466,9 @@ function plot_indicators_other(ds,id) date_ticks([sub_1 sub_2 sub_3],'x','yyyy','KeepLimits'); end - figure_title('Other Indicators'); + figure_title(f,'Other Indicators'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -542,11 +538,9 @@ function plot_pca(ds,id) date_ticks(sub_2,'x','yyyy','KeepLimits'); end - figure_title('Principal Component Analysis'); + figure_title(f,'Principal Component Analysis'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end diff --git a/ScriptsMeasures/run_connectedness.m b/ScriptsMeasures/run_connectedness.m index 178f311..f49ca96 100644 --- a/ScriptsMeasures/run_connectedness.m +++ b/ScriptsMeasures/run_connectedness.m @@ -381,11 +381,9 @@ function plot_indicators(ds,id) sub_2_position = get(sub_2,'Position'); set(sub_1,'Position',[sub_2_position(1) sub_1_position(2) sub_2_position(3) sub_2_position(4)]); - figure_title('Indicators'); + figure_title(f,'Indicators'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -473,11 +471,9 @@ function plot_network(ds,id) labels = text((xy(:,1) .* 1.075), (xy(:,2) .* 1.075),ds.FirmNames,'FontSize',10); set(labels,{'Rotation'},num2cell(theta * (180 / pi()))); - figure_title('Network Graph'); + figure_title(f,'Network Graph'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -500,11 +496,9 @@ function plot_adjacency_matrix(ds,id) set(ax,'XAxisLocation','top','XTick',1.5:off,'XTickLabels',ds.FirmNames,'XTickLabelRotation',45); set(ax,'YDir','reverse','YTick',1.5:off,'YTickLabels',ds.FirmNames,'YTickLabelRotation',45); - figure_title('Average Adjacency Matrix'); + figure_title(f,'Average Adjacency Matrix'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -560,11 +554,9 @@ function plot_centralities(ds,id) set([sub_1 sub_2 sub_3 sub_4 sub_5 sub_6],'XLim',[0 (ds.N + 1)],'XTick',seq,'XTickLabelRotation',90); set([sub_1 sub_2 sub_3 sub_4 sub_5 sub_6],'YGrid','on'); - figure_title('Average Centrality Measures'); + figure_title(f,'Average Centrality Measures'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end diff --git a/ScriptsMeasures/run_cross_entropy.m b/ScriptsMeasures/run_cross_entropy.m index bc75d95..158f0fb 100644 --- a/ScriptsMeasures/run_cross_entropy.m +++ b/ScriptsMeasures/run_cross_entropy.m @@ -622,11 +622,9 @@ function plot_portfolios_coverage(ds,id) set(subs,'YGrid','on'); - figure_title('Reduced Portfolios Coverage'); + figure_title(f,'Reduced Portfolios Coverage'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -667,11 +665,9 @@ function plot_indicators(ds,id) date_ticks([sub_1 sub_2 sub_3],'x','yyyy','KeepLimits'); end - figure_title(['Indicators (RR=' num2str(ds.RR * 100) '%, ' ds.PW ', ' ds.MD ')']); + figure_title(f,['Indicators (RR=' num2str(ds.RR * 100) '%, ' ds.PW ', ' ds.MD ')']); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -732,17 +728,16 @@ function plot_dide(ds,id) set(ax,'XAxisLocation','top','XTick',1.5:(nc + 0.5),'XTickLabels',ds.PortfolioComponents,'XTickLabelRotation',45); set(ax,'YDir','reverse','YTick',1.5:(nc + 0.5),'YTickLabels',ds.PortfolioComponents,'YTickLabelRotation',45); - figure_title('Average Distress Dependency'); + figure_title(f,'Average Distress Dependency'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end function plot_sequence_dide(ds,id) nc = numel(ds.PortfolioComponents); + nc_ones = ones(1,nc); t = ds.T; dn = ds.DatesNum; @@ -751,7 +746,7 @@ function plot_sequence_dide(ds,id) ts_si = ds.SI; ts_sv = ds.SV; - data = [repmat({dn},1,nc); mat2cell(ts_si,t,ones(1,nc)); mat2cell(ts_sv,t,ones(1,nc))]; + data = [repmat({dn},1,nc); mat2cell(ts_si,t,nc_ones); mat2cell(ts_sv,t,nc_ones)]; sequence_titles = ds.PortfolioComponents; @@ -807,20 +802,22 @@ function plot_function(subs,data) xd = x(d) - 1; end - plot(subs(1),x,si,'Color',[0.000 0.447 0.741]); + sub_1 = subs(1); + plot(sub_1,x,si,'Color',[0.000 0.447 0.741]); if (~isempty(xd)) - hold(subs(1),'on'); - plot(subs(1),[xd xd],get(subs(1),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,[xd xd],get(sub_1,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); end - plot(subs(2),x,sv,'Color',[0.000 0.447 0.741]); + sub_2 = subs(2); + plot(sub_2,x,sv,'Color',[0.000 0.447 0.741]); if (~isempty(xd)) - hold(subs(2),'on'); - plot(subs(2),[xd xd],get(subs(2),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(2),'off'); + hold(sub_2,'on'); + plot(sub_2,[xd xd],get(sub_2,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_2,'off'); end end @@ -892,12 +889,13 @@ function plot_function(subs,data) xd = x(d) - 1; end - plot(subs(1),x,y,'Color',[0.000 0.447 0.741]); + sub_1 = subs(1); + plot(sub_1,x,y,'Color',[0.000 0.447 0.741]); if (~isempty(xd)) - hold(subs(1),'on'); - plot(subs(1),[xd xd],get(subs(1),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,[xd xd],get(sub_1,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); end end diff --git a/ScriptsMeasures/run_cross_quantilogram.m b/ScriptsMeasures/run_cross_quantilogram.m index a5b3e33..e49129f 100644 --- a/ScriptsMeasures/run_cross_quantilogram.m +++ b/ScriptsMeasures/run_cross_quantilogram.m @@ -448,17 +448,19 @@ function plot_function(subs,data) cq_to_cl = data{6}; cq_to_ch = data{7}; - bar(subs(1),x,cq_from,0.6,'EdgeColor','none','FaceColor',[0.749 0.862 0.933]); - hold(subs(1),'on'); - plot(subs(1),x,cq_from_cl,'Color',[1.000 0.400 0.400],'LineWidth',1); - plot(subs(1),x,cq_from_ch,'Color',[1.000 0.400 0.400],'LineWidth',1); - hold(subs(1),'off'); - - bar(subs(2),x,cq_to,0.6,'EdgeColor','none','FaceColor',[0.749 0.862 0.933]); - hold(subs(2),'on'); - plot(subs(2),x,cq_to_cl,'Color',[1.000 0.400 0.400],'LineWidth',1); - plot(subs(2),x,cq_to_ch,'Color',[1.000 0.400 0.400],'LineWidth',1); - hold(subs(2),'off'); + sub_1 = subs(1); + bar(sub_1,x,cq_from,0.6,'EdgeColor','none','FaceColor',[0.749 0.862 0.933]); + hold(sub_1,'on'); + plot(sub_1,x,cq_from_cl,'Color',[1.000 0.400 0.400],'LineWidth',1); + plot(sub_1,x,cq_from_ch,'Color',[1.000 0.400 0.400],'LineWidth',1); + hold(sub_1,'off'); + + sub_2 = subs(2); + bar(sub_2,x,cq_to,0.6,'EdgeColor','none','FaceColor',[0.749 0.862 0.933]); + hold(sub_2,'on'); + plot(sub_2,x,cq_to_cl,'Color',[1.000 0.400 0.400],'LineWidth',1); + plot(sub_2,x,cq_to_ch,'Color',[1.000 0.400 0.400],'LineWidth',1); + hold(sub_2,'off'); end diff --git a/ScriptsMeasures/run_cross_sectional.m b/ScriptsMeasures/run_cross_sectional.m index f0fd662..3a5c889 100644 --- a/ScriptsMeasures/run_cross_sectional.m +++ b/ScriptsMeasures/run_cross_sectional.m @@ -463,11 +463,9 @@ function plot_idiosyncratic_averages(ds,id) date_ticks([sub_1 sub_2 sub_3],'x','yyyy','KeepLimits'); end - figure_title('Idiosyncratic Averages'); + figure_title(f,'Idiosyncratic Averages'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -513,11 +511,9 @@ function plot_systemic_averages(ds,id) y_tick_labels = arrayfun(@(x)sprintf('%.0f',x),y_ticks,'UniformOutput',false); set(subs(5:6),'YTick',y_ticks,'YTickLabel',y_tick_labels); - figure_title('Systemic Averages'); + figure_title(f,'Systemic Averages'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -580,9 +576,7 @@ function plot_correlations(ds,id) annotation('TextBox',[0 0 1 1],'String','Correlation Matrix','EdgeColor','none','FontName','Helvetica','FontSize',14,'HorizontalAlignment','center'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -673,11 +667,9 @@ function plot_rankings(ds,id) set(sub_2,'YTickLabel',tl_new); end - figure_title('Rankings (Kendall''s W)'); + figure_title(f,'Rankings (Kendall''s W)'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -749,25 +741,28 @@ function plot_function(subs,data) xd = x_caviar(d) - 1; end - plot(subs(1),x_caviar,caviar,'Color',[0.000 0.447 0.741]); + sub_1 = subs(1); + plot(sub_1,x_caviar,caviar,'Color',[0.000 0.447 0.741]); if (~isempty(xd)) - hold(subs(1),'on'); - plot(subs(1),[xd xd],get(subs(1),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,[xd xd],get(sub_1,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); end - plot(subs(2),x_ir,ir_fm(:,1),'Color',[0.000 0.447 0.741]); - hold(subs(2),'on'); - plot(subs(2),x_ir,ir_fm(:,2),'Color',[1.000 0.400 0.400],'LineStyle','--'); - plot(subs(2),x_ir,ir_fm(:,3),'Color',[1.000 0.400 0.400],'LineStyle','--'); - hold(subs(2),'off'); + sub_2 = subs(2); + plot(sub_2,x_ir,ir_fm(:,1),'Color',[0.000 0.447 0.741]); + hold(sub_2,'on'); + plot(sub_2,x_ir,ir_fm(:,2),'Color',[1.000 0.400 0.400],'LineStyle','--'); + plot(sub_2,x_ir,ir_fm(:,3),'Color',[1.000 0.400 0.400],'LineStyle','--'); + hold(sub_2,'off'); - plot(subs(3),x_ir,ir_mf(:,1),'Color',[0.000 0.447 0.741]); - hold(subs(3),'on'); - plot(subs(3),x_ir,ir_mf(:,2),'Color',[1.000 0.400 0.400],'LineStyle','--'); - plot(subs(3),x_ir,ir_mf(:,3),'Color',[1.000 0.400 0.400],'LineStyle','--'); - hold(subs(3),'off'); + sub_3 = subs(3); + plot(sub_3,x_ir,ir_mf(:,1),'Color',[0.000 0.447 0.741]); + hold(sub_3,'on'); + plot(sub_3,x_ir,ir_mf(:,2),'Color',[1.000 0.400 0.400],'LineStyle','--'); + plot(sub_3,x_ir,ir_mf(:,3),'Color',[1.000 0.400 0.400],'LineStyle','--'); + hold(sub_3,'off'); end @@ -834,12 +829,13 @@ function plot_function(subs,data) xd = x(d) - 1; end - plot(subs(1),x,y,'Color',[0.000 0.447 0.741]); + sub_1 = subs(1); + plot(sub_1,x,y,'Color',[0.000 0.447 0.741]); if (~isempty(xd)) - hold(subs(1),'on'); - plot(subs(1),[xd xd],get(subs(1),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,[xd xd],get(sub_1,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); end end diff --git a/ScriptsMeasures/run_default.m b/ScriptsMeasures/run_default.m index aa89e58..b222dcc 100644 --- a/ScriptsMeasures/run_default.m +++ b/ScriptsMeasures/run_default.m @@ -531,11 +531,9 @@ function plot_distances(ds,id) l_position = get(l,'Position'); set(l,'Position',[0.4683 0.4799 l_position(3) l_position(4)]); - figure_title('Distances'); + figure_title(f,'Distances'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -563,11 +561,9 @@ function plot_dip(ds,id) set(findobj(f,'-regexp','Tag','\w*Whisker'),'LineStyle','-'); set(sub_2,'TickLength',[0 0],'XTick',[],'XTickLabels',[]); - figure_title('Distress Insurance Premium'); + figure_title(f,'Distress Insurance Premium'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -609,11 +605,9 @@ function plot_rankings(ds,id) set(sub_2,'YDir','reverse','YTick',off,'YTickLabels',labels,'YTickLabelRotation',45); title(sub_2,'Ranking Concordance'); - figure_title('Rankings (Kendall''s W)'); + figure_title(f,'Rankings (Kendall''s W)'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -654,11 +648,9 @@ function plot_scca(ds,id) date_ticks([sub_1 sub_2 sub_3],'x','yyyy','KeepLimits'); end - figure_title(['Systemic CCA (' ds.OP ')']); + figure_title(f,['Systemic CCA (' ds.OP ')']); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -730,18 +722,19 @@ function plot_function(subs,data,is_distance) xd = x(d) - 1; end - plot(subs(1),x,y,'Color',[0.000 0.447 0.741]); + sub_1 = subs(1); + plot(sub_1,x,y,'Color',[0.000 0.447 0.741]); if (is_distance) - hold(subs(1),'on'); - plot(subs(1),x,zeros(numel(x),1),'Color',[1.000 0.400 0.400]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,x,zeros(numel(x),1),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); end if (~isempty(xd)) - hold(subs(1),'on'); - plot(subs(1),[xd xd],get(subs(1),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,[xd xd],get(sub_1,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); end end diff --git a/ScriptsMeasures/run_liquidity.m b/ScriptsMeasures/run_liquidity.m index e7874f3..e8fbccf 100644 --- a/ScriptsMeasures/run_liquidity.m +++ b/ScriptsMeasures/run_liquidity.m @@ -410,11 +410,9 @@ function plot_averages(ds,id) end end - figure_title('Averages'); + figure_title(f,'Averages'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -512,12 +510,13 @@ function plot_function(subs,data,k) xd = x(d) - 1; end - plot(subs(1),x,y1,'Color',[0.000 0.447 0.741]); + sub_1 = subs(1); + plot(sub_1,x,y1,'Color',[0.000 0.447 0.741]); if (~isempty(xd)) - hold(subs(1),'on'); - plot(subs(1),[xd xd],get(subs(1),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,[xd xd],get(sub_1,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); end if (k == 2) @@ -606,12 +605,13 @@ function plot_function(subs,data) xd = x(d) - 1; end - plot(subs(1),x,y,'Color',[0.000 0.447 0.741]); + sub_1 = subs(1); + plot(sub_1,x,y,'Color',[0.000 0.447 0.741]); if (~isempty(xd)) - hold(subs(1),'on'); - plot(subs(1),[xd xd],get(subs(1),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,[xd xd],get(sub_1,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); end end diff --git a/ScriptsMeasures/run_regime_switching.m b/ScriptsMeasures/run_regime_switching.m index b6f777d..991b272 100644 --- a/ScriptsMeasures/run_regime_switching.m +++ b/ScriptsMeasures/run_regime_switching.m @@ -586,11 +586,9 @@ function plot_indicators(ds,target,id) t2_position = get(t2,'Position'); set(t2,'Position',[0.4783 t2_position(2) t2_position(3)]); - figure_title(['Indicators ' model]); + figure_title(f,['Indicators ' model]); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -769,30 +767,34 @@ function plot_function(subs,data,k) tm_cmap = [0.65 0.65 0.65; 1 1 1; 0.749 0.862 0.933]; end - plot(subs(1),x,cs2,'Color',[0.000 0.447 0.741]); + sub_1 = subs(1); + plot(sub_1,x,cs2,'Color',[0.000 0.447 0.741]); if (~isempty(xd)) - hold(subs(1),'on'); - plot(subs(1),[xd xd],get(subs(1),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,[xd xd],get(sub_1,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); end - pcolor(subs(2),padarray(tmn,[1 1],'post')); - colormap(subs(2),tm_cmap); - text(subs(2),tm_x,tm_y,tm_txt,'FontSize',9 + 4 - k,'HorizontalAlignment','center'); + sub_2 = subs(2); + pcolor(sub_2,padarray(tmn,[1 1],'post')); + colormap(sub_2,tm_cmap); + text(sub_2,tm_x,tm_y,tm_txt,'FontSize',9 + 4 - k,'HorizontalAlignment','center'); - plot(subs(3),x,r,'Color',[0.65 0.65 0.65]) - hold(subs(3),'on'); - area(subs(3),x,sprob_hv,'EdgeColor',[0.000 0.447 0.741],'FaceAlpha',0.5,'FaceColor',[0.749 0.862 0.933]); - hold(subs(3),'off'); + sub_3 = subs(3); + plot(sub_3,x,r,'Color',[0.650 0.650 0.650]) + hold(sub_3,'on'); + area(sub_3,x,sprob_hv,'EdgeColor',[0.000 0.447 0.741],'FaceAlpha',0.5,'FaceColor',[0.749 0.862 0.933]); + hold(sub_3,'off'); if (~isempty(xd)) - hold(subs(3),'on'); - plot(subs(3),[xd xd],get(subs(3),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(3),'off'); + hold(sub_3,'on'); + plot(sub_3,[xd xd],get(sub_3,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_3,'off'); end - bar(subs(4),1:k,dur,'FaceColor',[0.749 0.862 0.933]); + sub_4 = subs(4); + bar(sub_4,1:k,dur,'FaceColor',[0.749 0.862 0.933]); end diff --git a/ScriptsMeasures/run_spillover.m b/ScriptsMeasures/run_spillover.m index d276cdc..b6af826 100644 --- a/ScriptsMeasures/run_spillover.m +++ b/ScriptsMeasures/run_spillover.m @@ -348,11 +348,9 @@ function plot_index(ds,id) set(findobj(f,'-regexp','Tag','\w*Whisker'),'LineStyle','-'); set(sub_2,'TickLength',[0 0],'XTick',[],'XTickLabels',[]); - figure_title('Spillover Index'); + figure_title(f,'Spillover Index'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -400,11 +398,9 @@ function plot_spillovers(ds,id) date_ticks([sub_1 sub_2 sub_3],'x','yyyy','KeepLimits'); end - figure_title(['Spillovers (' ds.FEVD ', H=' num2str(ds.H) ', LAGS=' num2str(ds.Lags) ')']); + figure_title(f,['Spillovers (' ds.FEVD ', H=' num2str(ds.H) ', LAGS=' num2str(ds.Lags) ')']); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -482,28 +478,31 @@ function plot_function(subs,data) xd = x(d) - 1; end - plot(subs(1),x,from,'Color',[0.000 0.447 0.741]); + sub_1 = subs(1); + plot(sub_1,x,from,'Color',[0.000 0.447 0.741]); if (~isempty(xd)) - hold(subs(1),'on'); - plot(subs(1),[xd xd],get(subs(1),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,[xd xd],get(sub_1,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); end - plot(subs(2),x,to,'Color',[0.000 0.447 0.741]); - hold(subs(2),'on'); - plot(subs(2),x,ones(numel(x),1),'Color',[1.000 0.400 0.400]); + sub_2 = subs(2); + plot(sub_2,x,to,'Color',[0.000 0.447 0.741]); + hold(sub_2,'on'); + plot(sub_2,x,ones(numel(x),1),'Color',[1.000 0.400 0.400]); if (~isempty(xd)) - plot(subs(2),[xd xd],get(subs(2),'YLim'),'Color',[1.000 0.400 0.400]); + plot(sub_2,[xd xd],get(sub_2,'YLim'),'Color',[1.000 0.400 0.400]); end - hold(subs(2),'off'); + hold(sub_2,'off'); - plot(subs(3),x,net,'Color',[0.000 0.447 0.741]); - hold(subs(3),'on'); - plot(subs(3),x,zeros(numel(x),1),'Color',[1.000 0.400 0.400]); + sub_3 = subs(3); + plot(sub_3,x,net,'Color',[0.000 0.447 0.741]); + hold(sub_3,'on'); + plot(sub_3,x,zeros(numel(x),1),'Color',[1.000 0.400 0.400]); if (~isempty(xd)) - plot(subs(3),[xd xd],get(subs(3),'YLim'),'Color',[1.000 0.400 0.400]); + plot(sub_3,[xd xd],get(sub_3,'YLim'),'Color',[1.000 0.400 0.400]); end - hold(subs(3),'off'); + hold(sub_3,'off'); end diff --git a/ScriptsMeasures/run_tail_dependence.m b/ScriptsMeasures/run_tail_dependence.m index 8d0048a..62fda17 100644 --- a/ScriptsMeasures/run_tail_dependence.m +++ b/ScriptsMeasures/run_tail_dependence.m @@ -331,11 +331,9 @@ function plot_asymptotic_indicators(ds,id) date_ticks([sub_1 sub_2],'x','yyyy','KeepLimits'); end - figure_title('Asymptotic Dependence Indicators'); + figure_title(f,'Asymptotic Dependence Indicators'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end @@ -398,13 +396,14 @@ function plot_function(subs,data) else xd = x(d) - 1; end - - plot(subs(1),x,y,'Color',[0.000 0.447 0.741]); + + sub_1 = subs(1); + plot(sub_1,x,y,'Color',[0.000 0.447 0.741]); if (~isempty(xd)) - hold(subs(1),'on'); - plot(subs(1),[xd xd],get(subs(1),'YLim'),'Color',[1.000 0.400 0.400]); - hold(subs(1),'off'); + hold(sub_1,'on'); + plot(sub_1,[xd xd],get(sub_1,'YLim'),'Color',[1.000 0.400 0.400]); + hold(sub_1,'off'); end end @@ -435,11 +434,9 @@ function plot_frm(ds,id) set(findobj(f,'-regexp','Tag','\w*Whisker'),'LineStyle','-'); set(sub_2,'TickLength',[0 0],'XTick',[],'XTickLabels',[]); - figure_title('Financial Risk Meter'); + figure_title(f,'Financial Risk Meter'); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + maximize_figure(f); end diff --git a/ScriptsPlotting/figure_title.m b/ScriptsPlotting/figure_title.m index 01a44a4..489c2d6 100644 --- a/ScriptsPlotting/figure_title.m +++ b/ScriptsPlotting/figure_title.m @@ -1,4 +1,5 @@ % [INPUT] +% f = A valid figure instance. % t = A string representing the figure title. % % [OUTPUT] @@ -10,25 +11,28 @@ if (isempty(ip)) ip = inputParser(); + ip.addRequired('f',@(x)validateattributes(x,{'matlab.ui.Figure'},{'scalar'})); ip.addRequired('s',@(x)validateattributes(x,{'char'},{'nonempty' 'size' [1 NaN]})); end ip.parse(varargin{:}); + ipr = ip.Results; + f = ipr.f; + s = ipr.s; nargoutchk(0,1); if (nargout == 0) - figure_title_internal(ipr.s); + figure_title_internal(f,s); else - t = figure_title_internal(ipr.s); + t = figure_title_internal(f,s); end end -function t = figure_title_internal(s) +function t = figure_title_internal(f,s) - f = gcf(); f_font_size = get(f,'DefaultAxesFontSize') + 4; f_units = get(f,'Units'); diff --git a/ScriptsPlotting/maximize_figure.m b/ScriptsPlotting/maximize_figure.m new file mode 100644 index 0000000..a3606d6 --- /dev/null +++ b/ScriptsPlotting/maximize_figure.m @@ -0,0 +1,37 @@ +% [INPUT] +% f = A valid figure instance. + +function maximize_figure(varargin) + + persistent ip; + + if (isempty(ip)) + ip = inputParser(); + ip.addRequired('f',@(x)validateattributes(x,{'matlab.ui.Figure'},{'scalar'})); + end + + ip.parse(varargin{:}); + + ipr = ip.Results; + f = ipr.f; + + nargoutchk(0,0); + + maximize_figure_internal(f); + +end + +function maximize_figure_internal(f) + + pause(0.1); + + if (verLessThan('MATLAB','9.4')) + frame = get(f,'JavaFrame'); %#ok + set(frame,'Maximized',true); + else + set(f,'WindowState','maximized'); + end + + drawnow(); + +end diff --git a/ScriptsPlotting/sequential_plot.m b/ScriptsPlotting/sequential_plot.m index 3df4db8..88af8a7 100644 --- a/ScriptsPlotting/sequential_plot.m +++ b/ScriptsPlotting/sequential_plot.m @@ -143,9 +143,7 @@ function sequential_plot_internal(core,id) set(t,'Position',[0.4783 t_position(2) t_position(3)]); end end - - figure_title([core.InnerTitle ' - ' core.SequenceTitles{1}]); - + setappdata(f,'N',core.N); setappdata(f,'Data',core.Data); setappdata(f,'Function',core.Function); @@ -156,9 +154,9 @@ function sequential_plot_internal(core,id) setappdata(f,'Offset',1); setappdata(f,'Subs',subs); - pause(0.01); - frame = get(f,'JavaFrame'); %#ok - set(frame,'Maximized',true); + figure_title(f,[core.InnerTitle ' - ' core.SequenceTitles{1}]); + + maximize_figure(f); end @@ -211,6 +209,7 @@ function sequential_plot_internal(core,id) plots_rows = plots_allocation(1); plots_columns = plots_allocation(2); plots_grid = repmat(1:plots_columns,plots_rows,1) + repmat(plots_columns .* (0:plots_rows-1),plots_columns,1).'; + plot_cells_count = false(size(plots_grid)); plots_adjustable = false(plots,1); plots_slots = cell(plots,1); @@ -218,75 +217,41 @@ function sequential_plot_internal(core,id) for i = 1:plots plot_span = plots_span{i}; - if (isscalar(plot_span)) - [check,indices] = ismember(plot_span,plots_grid); + [check,indices] = ismember(plot_span,plots_grid); - if (~check) - error(['The structure field ''PlotsSpan'' is invalid.' new_line() 'Expected content ' num2str(i) ' to define valid grid cells.']); - end - - plot_cells = false(size(plots_grid)); - plot_cells(indices) = true; - - rc = 1; - else - if ((numel(plot_span) == 2) && (plot_span(1) ~= (plot_span(2) - 1))) - [r1,c1] = find(plots_grid == plot_span(1),1,'first'); - - if (isempty(r1) || isempty(c1)) - error(['The structure field ''PlotsSpan'' is invalid.' new_line() 'Expected content ' num2str(i) ' to define valid grid cells.']); - end - - [r2,c2] = find(plots_grid == plot_span(2),1,'first'); - - if (isempty(r2) || isempty(c2)) - error(['The structure field ''PlotsSpan'' is invalid.' new_line() 'Expected content ' num2str(i) ' to define valid grid cells.']); - end - - plot_cells = (plots_grid == plot_span(1)) + (plots_grid == plot_span(2)); - plot_cells(r1:r2,c1:c2) = 1; - plot_cells = logical(plot_cells); - - rc = sum(plot_cells,2); - else - [check,indices] = ismember(plot_span,plots_grid); - - if (~all(check)) - error(['The structure field ''PlotsSpan'' is invalid.' new_line() 'Expected content ' num2str(i) ' to define valid grid cells.']); - end + if (~all(check)) + error(['The structure field ''PlotsSpan'' is invalid.' new_line() 'Expected content ' num2str(i) ' to define valid grid cells.']); + end - if (~all(diff(plot_span) == 1)) - error(['The structure field ''PlotsSpan'' is invalid.' new_line() 'Expected content ' num2str(i) ' to define contiguous grid cells.']); - end + plot_cells = false(size(plots_grid)); + plot_cells(indices) = true; - plot_cells = false(size(plots_grid)); - plot_cells(indices) = true; + chunks = arrayfun(@(s)plot_cells(s.SubarrayIdx{:}),regionprops(bwconncomp(plot_cells,4),'SubarrayIdx'),'UniformOutput',false); - rc = sum(plot_cells,2); - rc(rc == 0) = []; + if (numel(chunks) ~= 1) + error(['The structure field ''PlotsSpan'' is invalid.' new_line() 'Expected content ' num2str(i) ' to define a single subset of grid cells.']); + end - if (~isscalar(rc)) - [~,indices_a,indices_b] = intersect(plot_cells,plot_cells,'rows'); + plot_cells_isolated = chunks{1}; - if (~isscalar(indices_a) || ~isscalar(indices_b) || (indices_a ~= indices_b) || ~all(diff(rc) == 0)) - error(['The structure field ''PlotsSpan'' is invalid.' new_line() 'Expected content ' num2str(i) ' to define a valid subplot area.']); - end - end - end + if (any(any(plot_cells_isolated == 0))) + error(['The structure field ''PlotsSpan'' is invalid.' new_line() 'Expected content ' num2str(i) ' to define a contiguous subset of grid cells.']); end + + rc = unique(sum(plot_cells_isolated,2)); - if (any(rc == plots_columns)) + if (rc == plots_columns) plots_adjustable(i) = true; end plot_slots = plots_grid(plot_cells); - plots_slots{i} = plot_slots(:); - end + plots_slots{i} = sort(plot_slots(:)); - plots_slots = cell2mat(plots_slots); + plot_cells_count = plot_cells_count + plot_cells; + end - if (numel(unique(plots_slots)) ~= numel(plots_slots)) - error(['The structure field ''PlotsSpan'' is invalid.' new_line() 'Expected contents to define a non-overlapping subplot areas.']); + if (any(any(plot_cells_count > 1))) + error(['The structure field ''PlotsSpan'' is invalid.' new_line() 'Expected contents to define non-overlapping subplot areas.']); end end @@ -420,12 +385,14 @@ function draw_time_series(f,offset) end end - figure_title([inner_title ' - ' sequence_titles{offset}]); + figure_title(f,[inner_title ' - ' sequence_titles{offset}]); end function switch_time_series(obj,~) + set(obj,'Enable','off'); + f = get(obj,'Parent'); direction = get(obj,'String'); @@ -439,10 +406,7 @@ function switch_time_series(obj,~) set(obj_other,'Enable','on'); n = getappdata(f,'N'); - - if (offset == n) - set(obj,'Enable','off'); - end + obj_enable = offset < n; else offset = offset - 1; setappdata(f,'Offset',offset); @@ -450,11 +414,14 @@ function switch_time_series(obj,~) obj_other = findobj(f,'String','Next'); set(obj_other,'Enable','on'); - if (offset == 1) - set(obj,'Enable','off'); - end + obj_enable = offset > 1; end draw_time_series(f,offset); + if (obj_enable) + set(obj,'Enable','on'); + uicontrol(obj); + end + end diff --git a/Templates/TemplateBubblesDetection.xlsx b/Templates/TemplateBubblesDetection.xlsx index 365c84a..b08f206 100644 Binary files a/Templates/TemplateBubblesDetection.xlsx and b/Templates/TemplateBubblesDetection.xlsx differ diff --git a/run.m b/run.m index 18a63d5..1b72809 100644 --- a/run.m +++ b/run.m @@ -82,16 +82,16 @@ measures_setup = { % NAME ENABLED ANALYZE COMPARE FUNCTION 'BubblesDetection' true true true @(temp,out,analyze)run_bubbles_detection(ds,sn,temp,out,'WB',0.95,0,'FIX',NaN,analyze); - 'Component' false true true @(temp,out,analyze)run_component(ds,sn,temp,out,bw,0.99,0.98,0.05,0.2,0.75,analyze); - 'Connectedness' false true true @(temp,out,analyze)run_connectedness(ds,sn,temp,out,bw,0.05,false,0.06,analyze); - 'CrossEntropy' false true true @(temp,out,analyze)run_cross_entropy(ds,sn,temp,out,bw,'G',0.4,'W','N',analyze); - 'CrossQuantilogram' false true true @(temp,out,analyze)run_cross_quantilogram(ds,sn,temp,out,bw,0.05,60,'SB',0.05,100,analyze); - 'CrossSectional' false true true @(temp,out,analyze)run_cross_sectional(ds,sn,temp,out,0.95,0.40,0.08,0.40,3,analyze); - 'Default' false true true @(temp,out,analyze)run_default(ds,sn,temp,out,bw,'BSM',3,0.08,2,0.55,0.10,100,5,0.95,analyze); - 'Liquidity' false true true @(temp,out,analyze)run_liquidity(ds,sn,temp,out,bw,21,5,'B',500,0.01,0.0004,analyze); - 'RegimeSwitching' false true true @(temp,out,analyze)run_regime_switching(ds,sn,temp,out,true,true,true,analyze); - 'Spillover' false true true @(temp,out,analyze)run_spillover(ds,sn,temp,out,bw,10,'G',2,4,analyze); - 'TailDependence' false true true @(temp,out,analyze)run_tail_dependence(ds,sn,temp,out,bw,0.10,0.5,0.05,100,analyze); + 'Component' true true true @(temp,out,analyze)run_component(ds,sn,temp,out,bw,0.99,0.98,0.05,0.2,0.75,analyze); + 'Connectedness' true true true @(temp,out,analyze)run_connectedness(ds,sn,temp,out,bw,0.05,false,0.06,analyze); + 'CrossEntropy' true true true @(temp,out,analyze)run_cross_entropy(ds,sn,temp,out,bw,'G',0.4,'W','N',analyze); + 'CrossQuantilogram' true true true @(temp,out,analyze)run_cross_quantilogram(ds,sn,temp,out,bw,0.05,60,'SB',0.05,100,analyze); + 'CrossSectional' true true true @(temp,out,analyze)run_cross_sectional(ds,sn,temp,out,0.95,0.40,0.08,0.40,3,analyze); + 'Default' true true true @(temp,out,analyze)run_default(ds,sn,temp,out,bw,'BSM',3,0.08,2,0.55,0.10,100,5,0.95,analyze); + 'Liquidity' true true true @(temp,out,analyze)run_liquidity(ds,sn,temp,out,bw,21,5,'B',500,0.01,0.0004,analyze); + 'RegimeSwitching' true true true @(temp,out,analyze)run_regime_switching(ds,sn,temp,out,true,true,true,analyze); + 'Spillover' true true true @(temp,out,analyze)run_spillover(ds,sn,temp,out,bw,10,'G',2,4,analyze); + 'TailDependence' true true true @(temp,out,analyze)run_tail_dependence(ds,sn,temp,out,bw,0.10,0.5,0.05,100,analyze); }; enabled_all = [measures_setup{:,2}];