delay-discounting-analysis

How to: export figures

Export location

By default, figures will be exported to a temporary directory, generated by the Matlab tempname() function. This is will create some random folder in your temporary folder, on my mac this gives something like /private/tmp/tp9a9023eb_26e1_4c17_ad0f_1c9692d75f66, which will be different each time.

But when you want to export figures for publication, it’s probably better to provide a more meaningful export location. You can do this by providing a location with an optional key value pair when constructing the model object. For example:

myDataObject = Data(datapath,...
    'files', allFilesInFolder(datapath, 'txt'));
myModel = ModelHierarchicalExp1(myDataObject,....
    'savePath', desiredSavePath);

where desiredSavePath can be any absolute or relative path name. This should of course be a string.

In the example below, we fit the same dataset with two discount functions and export to two sensibly named subdirectories in an output folder in the current working directory:

myExpModel = ModelHierarchicalExp1(myDataObject,...
    'savePath', fullfile(pwd,'output','exponential_analysis'));
myHypModel = ModelHierarchicalLogk(myDataObject,...
    'savePath', fullfile(pwd,'output','hyperbolic_analysis'));

Export formats

The default export format for figures is .png, but we can change this to another file type (or multiple filetypes) through another key/value pair when we construct the model. For example, if we want to export in both png and pdf formats we can just provide this in the form of a cell array of strings where the strings are the desired formats.

myExpModel = ModelHierarchicalExp1(myDataObject,....
    'exportFormats', {'png', 'pdf'});

Turn exporting off

If for whatever reason you don’t want to export any figures, you switch the shouldExportPlots option to false, for example:

myExpModel = ModelHierarchicalExp1(myDataObject,....
    'shouldExportPlots', 'false');

More information about arguments are provided in the Parameter estimation options reference page.