Different fonts for Matlab plots exported to PDF

When exporting graphics from Stata or Matlab, it’s better to select a lossless/vectorized format instead of a rasterized pic. This ensures your image is high-quality and not grainy/pixelated.

Grainy exports

Poor quality, grainy image

Better quality export

Unfortunately, Matlab does not allow lossless PDF exports of pictures with non-standard fonts. (I’m not the first person to notice this problem. I failed to implement Juan Guerrero’s suggested solution.) Matlab will export the font in PNG no problem, but your image will appear grainy. If you try to export as a PDF, your fonts will be reverted to something weird. Obviously this doesn’t matter if you’re happy with the default fonts, but this bug does limit your ability to customize the output.

Thankfully, with the help of the nice people at Inkscape (https://inkscape.org/) there is a workaround.

  1. Install Inkscape
  2. Generate your figure in Matlab
  3. In “Export Setup”, change the Font to anything saved on your system. Export as Scalable Vector Graphic (SVG) file
  4. Open the SVG in Inkscape
  5. Save it a lossless PDF as, say, figure7.pdf
  6. Include in your LaTeX document with \includegraphics{figure7}


Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top