On Code Ocean, files need to be saved explicitly to /results
to be visible as results.
When you export a capsule, it will typically come with a /results
folder inside the exported folder. However, some users may not wish to have a new folder created for them (if, say, they are downloading the code and data separately rather than exporting the capsule as a whole) -- and their local workflow may be to just wait for figures to pop up in their IDE or terminal.
For these use cases, you can use either shell scripting or MATLAB syntax.
Shell:
DIRECTORY='../results'
if [ -d "$DIRECTORY" ]; then
# run your code
# save your figure
fi
MATLAB:
After generating your figure, you'd run something like
if ~usejava('desktop') saveas(gcf,'../results/figure1.pdf') end
If you have other languages you'd like to see syntax for, please let us know via live chat or an email to support@codeocean.com, and we'll amend this article accordingly.