Skip to content
Snippets Groups Projects
Commit 4199f577 authored by Johannes Pfeifer's avatar Johannes Pfeifer
Browse files

GSA scatter plots: clean up files and enable TeX-output

parent 94c13436
No related branches found
No related tags found
No related merge requests found
function indmcf = scatter_analysis(lpmat, xdata, options_scatter, options_) function scatter_analysis(lpmat, xdata, options_scatter, options_)
% scatter_analysis(lpmat, xdata, options_scatter, options_)
% Plot scatter plot analysis
% %
% Written by Marco Ratto % Written by Marco Ratto
% Joint Research Centre, The European Commission, % Joint Research Centre, The European Commission,
...@@ -6,7 +8,7 @@ function indmcf = scatter_analysis(lpmat, xdata, options_scatter, options_) ...@@ -6,7 +8,7 @@ function indmcf = scatter_analysis(lpmat, xdata, options_scatter, options_)
% %
% Copyright © 2017 European Commission % Copyright © 2017 European Commission
% Copyright © 2017 Dynare Team % Copyright © 2017-2023 Dynare Team
% %
% This file is part of Dynare. % This file is part of Dynare.
% %
...@@ -34,7 +36,6 @@ if options_.TeX ...@@ -34,7 +36,6 @@ if options_.TeX
end end
amcf_name = options_scatter.amcf_name; amcf_name = options_scatter.amcf_name;
amcf_title = options_scatter.amcf_title; amcf_title = options_scatter.amcf_title;
title = options_scatter.title;
fname_ = options_scatter.fname_; fname_ = options_scatter.fname_;
xparam1=[]; xparam1=[];
if isfield(options_scatter,'xparam1') if isfield(options_scatter,'xparam1')
...@@ -48,5 +49,9 @@ if ~options_.nograph ...@@ -48,5 +49,9 @@ if ~options_.nograph
if ~isempty(xparam1) if ~isempty(xparam1)
xx=xparam1; xx=xparam1;
end end
if options_.TeX
scatter_plots(lpmat, xdata, param_names_tex, '.', [fname_, '_', amcf_name], OutputDirectoryName, amcf_title, xx, options_)
else
scatter_plots(lpmat, xdata, param_names, '.', [fname_, '_', amcf_name], OutputDirectoryName, amcf_title, xx, options_) scatter_plots(lpmat, xdata, param_names, '.', [fname_, '_', amcf_name], OutputDirectoryName, amcf_title, xx, options_)
end end
end
function scatter_plots(X,xp,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, options_) function scatter_plots(X,xp,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, options_)
% scatter_plots(X,xp,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, options_)
% Pairwise scatter plots of the columns of x and y after Monte Carlo filtering
% Inputs:
% - X [double] nxk matrix with columns containing behavioural sample
% - xp [double] mxk matrix with columns containing non-behavioural sample
% - vnames [char] vector of variable names (default = numeric labels 1,2,3 etc.)
% - plotsymbol [char] plt symbol (default = '.' for npts > 100, 'o' for npts < 100
% - fnam [char] figure name
% - dirname [char] directory name
% - figtitle [char] figure title
% - xparam1 [double] parameter vector
% - options_ [struct] option structure
% %
% Written by Marco Ratto % Written by Marco Ratto
% Joint Research Centre, The European Commission, % Joint Research Centre, The European Commission,
% marco.ratto@ec.europa.eu % marco.ratto@ec.europa.eu
%
% Copyright © 2017 European Commission % Copyright © 2017 European Commission
% Copyright © 2017-2023 Dynare Team % Copyright © 2017-2023 Dynare Team
...@@ -23,23 +35,7 @@ function scatter_plots(X,xp,vnames,plotsymbol, fnam, dirname, figtitle, xparam1, ...@@ -23,23 +35,7 @@ function scatter_plots(X,xp,vnames,plotsymbol, fnam, dirname, figtitle, xparam1,
% You should have received a copy of the GNU General Public License % You should have received a copy of the GNU General Public License
% along with Dynare. If not, see <https://www.gnu.org/licenses/>. % along with Dynare. If not, see <https://www.gnu.org/licenses/>.
% PURPOSE: Pairwise scatter plots of the columns of x and y after
% Monte Carlo filtering
%---------------------------------------------------
% USAGE: scatter_mcf(x,y,vnames,pltsym,diagon)
% or scatter_mcf(x,y) which relies on defaults
% where:
% x = an nxk matrix with columns containing behavioural sample
% y = an mxk matrix with columns containing non-behavioural sample
% vnames = a vector of variable names
% (default = numeric labels 1,2,3 etc.)
% pltsym = a plt symbol
% (default = '.' for npts > 100, 'o' for npts < 100
[n,p] = size(X); [n,p] = size(X);
% X = X - ones(n,1)*min(Z);
% X = X ./ (ones(n,1)*max(Z));
nflag = 0; nflag = 0;
if nargin >=3 if nargin >=3
...@@ -47,8 +43,10 @@ if nargin >=3 ...@@ -47,8 +43,10 @@ if nargin >=3
end end
if nargin<4 || isempty(plotsymbol) if nargin<4 || isempty(plotsymbol)
if n*p<100, plotsymbol = 'o'; if n*p<100
else plotsymbol = '.'; plotsymbol = 'o';
else
plotsymbol = '.';
end end
end end
...@@ -71,7 +69,7 @@ end ...@@ -71,7 +69,7 @@ end
figtitle_tex=strrep(figtitle,'_','\_'); figtitle_tex=strrep(figtitle,'_','\_');
fig_nam_=[fnam]; fig_nam_=fnam;
hh_fig=dyn_figure(options_.nodisplay,'name',figtitle); hh_fig=dyn_figure(options_.nodisplay,'name',figtitle);
set(hh_fig,'userdata',{X,xp}) set(hh_fig,'userdata',{X,xp})
...@@ -90,7 +88,6 @@ for i = 1:p ...@@ -90,7 +88,6 @@ for i = 1:p
if i==j if i==j
h1=cumplot(X(:,j)); h1=cumplot(X(:,j));
set(h,'Tag','cumplot') set(h,'Tag','cumplot')
% set(h1,'color',[0 0 1], 'linestyle','--','LineWidth',1.5)
set(h1,'color',[0 0 1],'LineWidth',1.5) set(h1,'color',[0 0 1],'LineWidth',1.5)
if ~isempty(xparam1) if ~isempty(xparam1)
hold on, plot(xparam1([j j]),[0 1],'k--') hold on, plot(xparam1([j j]),[0 1],'k--')
...@@ -101,12 +98,8 @@ for i = 1:p ...@@ -101,12 +98,8 @@ for i = 1:p
grid off grid off
end end
set(gca,'YTickLabel',[],'YTick',[]); set(gca,'YTickLabel',[],'YTick',[]);
else
if j>i
plot(X(:,i),X(:,j),[plotsymbol,'b'])
else else
plot(X(:,i),X(:,j),[plotsymbol,'b']) plot(X(:,i),X(:,j),[plotsymbol,'b'])
end
set(h,'Tag','scatter') set(h,'Tag','scatter')
%% %%
...@@ -134,7 +127,6 @@ for i = 1:p ...@@ -134,7 +127,6 @@ for i = 1:p
hold on, plot(xparam1(i),xparam1(j),'s','MarkerFaceColor',[0 0.75 0],'MarkerEdgeColor',[0 0.75 0]) hold on, plot(xparam1(i),xparam1(j),'s','MarkerFaceColor',[0 0.75 0],'MarkerEdgeColor',[0 0.75 0])
end end
hold off; hold off;
% axis([-0.1 1.1 -0.1 1.1])
if i<p if i<p
set(gca,'YTickLabel',[],'YTick',[]); set(gca,'YTickLabel',[],'YTick',[]);
else else
...@@ -149,16 +141,26 @@ for i = 1:p ...@@ -149,16 +141,26 @@ for i = 1:p
end end
if i==1 if i==1
if nflag == 1 if nflag == 1
if options_.TeX
ylabel(vnames(j,:),'Rotation',45,'interpreter','latex', ...
'HorizontalAlignment','right','VerticalAlignment','middle');
else
ylabel(vnames(j,:),'Rotation',45,'interpreter','none', ... ylabel(vnames(j,:),'Rotation',45,'interpreter','none', ...
'HorizontalAlignment','right','VerticalAlignment','middle'); 'HorizontalAlignment','right','VerticalAlignment','middle');
end
else else
ylabel([num2str(j),' '],'Rotation',90) ylabel([num2str(j),' '],'Rotation',90)
end end
end end
if j==1 if j==1
if nflag == 1 if nflag == 1
if options_.TeX
title(vnames(i,:),'interpreter','latex','Rotation',45, ...
'HorizontalAlignment','left','VerticalAlignment','bottom')
else
title(vnames(i,:),'interpreter','none','Rotation',45, ... title(vnames(i,:),'interpreter','none','Rotation',45, ...
'HorizontalAlignment','left','VerticalAlignment','bottom') 'HorizontalAlignment','left','VerticalAlignment','bottom')
end
else else
title(num2str(i)) title(num2str(i))
end end
...@@ -166,10 +168,6 @@ for i = 1:p ...@@ -166,10 +168,6 @@ for i = 1:p
drawnow drawnow
end end
end end
% if ~isoctave
% annotation('textbox', [0.1,0,0.35,0.05],'String', beha_name,'Color','Blue','horizontalalignment','center','interpreter','none');
% annotation('textbox', [0.55,0,0.35,0.05],'String', non_beha_name,'Color','Red','horizontalalignment','center','interpreter','none');
% end
if ~nograph if ~nograph
dyn_saveas(hh_fig,[dirname,filesep,fig_nam_],options_.nodisplay,options_.graph_format); dyn_saveas(hh_fig,[dirname,filesep,fig_nam_],options_.nodisplay,options_.graph_format);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment