Skip to content

Commit

Permalink
#191 plotUnivarateSummary now callable method of model
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben Vincent committed Jun 2, 2017
1 parent 23f056d commit 1068d9b
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 15 deletions.
39 changes: 39 additions & 0 deletions ddToolbox/models/Model.m
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,49 @@ function plotDiscountFunctionsOverlaid(obj)
% set(gca,'FontSize',10)
drawnow
end

function plotUnivarateSummary(obj, varargin)
%plotUnivarateSummary Creates a forest plot of univariate summary stats about the model parameters requested

p = inputParser;
p.FunctionName = mfilename;
p.addParameter('variablesToPlot', 'all', @(x) isstr(x)|iscellstr(x));
p.parse(varargin{:});

if iscellstr(p.Results.variablesToPlot)
% user is providing a cell array of strings, which we will assume corresponds to specific variable names.
variables = p.Results.variablesToPlot;
else
% user privided a string, hopefully one of the acceptable inputs below
switch p.Results.variablesToPlot
case{'all'}
variables = obj.varList.participantLevel;
otherwise
error('unrecognised input provided for ''variablesToPlot''.')
end
end

obj.coda.plotUnivariateSummaries(variables,...
obj.plotOptions,...
obj.data.getParticipantNames());

plot_savename = 'UnivariateSummary';
obj.export_it(plot_savename)

end

end

methods (Access = protected)

function export_it(obj, savename)
if obj.plotOptions.shouldExportPlots
myExport(obj.plotOptions.savePath,...
savename,...
'suffix', obj.modelFilename,...
'formats', obj.plotOptions.exportFormats)
end
end

function plotAllExperimentFigures(obj)
% this is a wrapper function to loop over all data files, producing multi-panel figures. This is implemented by the experimentMultiPanelFigure method, which may be overridden by subclasses if need be.
Expand Down
23 changes: 8 additions & 15 deletions ddToolbox/models/parametric_models/Parametric.m
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ function plot(obj, varargin)
%% Plot functions that use data from all participants ========

% Plot univariate summary stats
plot_savename = 'UnivariateSummary';
variables = obj.varList.participantLevel;
obj.coda.plotUnivariateSummaries(variables,...
obj.plotOptions,...
obj.data.getParticipantNames());
export_it(plot_savename)
obj.plotUnivarateSummary('variablesToPlot', 'all')
% plot_savename = 'UnivariateSummary';
% variables = obj.varList.participantLevel;
% obj.coda.plotUnivariateSummaries(variables,...
% obj.plotOptions,...
% obj.data.getParticipantNames());
% obj.export_it(plot_savename)

% summary figure of core discounting parameters
plot_savename = 'summary_plot';
Expand All @@ -55,7 +56,7 @@ function plot(obj, varargin)
[1 0 0],...
obj.plotOptions,...
obj.varList.discountFunctionParams)
export_it(plot_savename)
obj.export_it(plot_savename)


obj.plotDiscountFunctionGrid();
Expand Down Expand Up @@ -83,14 +84,6 @@ function plot(obj, varargin)
dfPlotFunc = @(fh,n) obj.plotDiscountFunction(fh,n);
obj.postPred.plot(obj.plotOptions, obj.modelFilename, dfPlotFunc)

function export_it(savename)
if obj.plotOptions.shouldExportPlots
myExport(obj.plotOptions.savePath,...
savename,...
'suffix', obj.modelFilename,...
'formats', obj.plotOptions.exportFormats)
end
end
end


Expand Down

0 comments on commit 1068d9b

Please sign in to comment.