I am looking to export my MATLAB plot as a high quality figure. Specifically, I would like to save it as a vector based file format such as EPS or SVG.
I have tried print and saveas commands:
saveas(h,'myFileName','epsc2');
print('-r150','-depsc2', 'myFilename');
On all occasions this produces poor quality parts of the graph, although the axis-labels are indeed vector. Why does MatLab do some horrible rendering before putting it into an EPS?
Example of poor quality plot here:
http://users.ox.ac.uk/~pemb2372/myFileName.eps
Edit:
It is also worth noting that if you use a Mac viewing an EPS file from Matlab, ‘Preview’ app may render inner graph content rasterized and poor quality, while leaving the axis and labels vectorized and high quality. This is very misleading but when you open said EPS file in, for example, Inkscape, the quality is actually vector and quite high.
Edit 2:
My university hosting account has expired, so you can no longer view the figure. Suffice it to say that it showed a poor quality raster-style plot within high quality beautiful axis lines, ticks and labels.
Matlab can export to pdf with better quality than EPS, but with its own caveats of setting decent margins and font sizes.
edit:
Examples are similar to the EPS case as explained in the help of e.g.
print:or
You might also want to take a look at the
PaperSize,PaperPositionandPaperUnitsproperties of your figure (by means of thesetandgetfunctions).edit: Another option is to use one of the functions available on FileExchange such as the ones mentioned by @user664303 below. My personal favorite for use with LaTeX is
matlab2tikzfor which the latest version can be gotten from GitHub. Together with theexternallibrary of TikZ, I think this delivers some of the most nicest graphs around.Probably it’s also best to mention that I have been actively involved in the
matlab2tikzproject since 2012.