Exporting Figures in Matlab
Exporting figures from Matlab to eps (or many other formats) is relatively straightforward using the print -d<format> command. A problem rises, however, when you try to use the pdf format as the resulting pdf has incorrect margins and does not work well when you include it in a latex document. Also, it sometimes nice to have multiple types of figures created using a single Matlab command.
export_fig nicefig -pdf -eps % saves current fig as pdf and eps
saves the current figure as both
nicefig.eps. For archiving and/or publications, it is often convenient to automatically name figures and save them in four formats: eps, pdf, png, and fig (matlab). The script savefig.m does this by wrapping export_fig.
A second option is to use savefig. It has the advantage of less dependencies, however the output is not as nice (e.g., pdfs have untrimmed margins).
savefig('nicefig', 'pdf'); % saves current fig as pdf
If you want to get eps and convert it manually,
savefig('nicefig', 'eps'); % saves current fig as eps
After generating the eps, use ps2pdf to crop (maintaining current image resolution).
ps2pdf -dEPSCrop -dAutoRotatePages=/None -dAutoFilterColorImages=false -dColorImageFilter=/FlateEncode -dUseFlateCompression=true nicefig.eps
does this automatically (to install on ubuntu:
sudo aptitude install texlive-extra-utils).