How to create prettier figures in Matlab

This post originally appeared on my previous blog.

So, two weeks into the blog and I was already feeling unsure about what to write. I turned to this post for some inspiration. I particularly like this one: “Answering the same question a second time? Put it in a blog post.” The question I was asked at least twice quite recently is… How do you make pretty figures in Matlab?

I present to you one of the figures from a recent paper. Before:

hist_before

And after:

hist_after

So much prettier, and better fitting to the rest of the paper!
The tricks are:

1) Do not use default colors. Mine are [0.5 0.5 0] and [0 0.5 0.75]. Other combinations of 0.5 and 0.75 are pretty good too.

2) If something has an ‘interpreter’ property, set it to LateX. Or simply do:

set(0,'defaulttextinterpreter','latex')

3) If it does not have an `interpreter’ property, set the font to ‘Georgia’. Now, if you try to save your figure as a PDF, the Georgia font will disappear. That’s why you should also:

4) Use this function. It makes sure that your PDF version looks EXACTLY the same as how you see it in Matlab. By EXACTLY I mean that you also get the grey background. If you don’t want that, add the following lines to your figure:

set(gcf,'Color',[1 1 1])
set(gca,'Color',[1 1 1])
set(gcf, 'InvertHardCopy', 'off');

And that’s about it! I hope that’s helpful 🙂

Leave a Reply