
% set colors according to yet another scale % if labels are too long to fit, use the xticklabelrotation with about -30 Set(h(1), 'marker', 'none') % remove marker

% if we want each bar to have a different color, loopīar(b, mean(dat(:,b)), 'FaceColor', colors(b, : ), 'EdgeColor', 'none', 'BarWidth', 0.6) Subplot(4,7,6) % rather than a square plot, make it thinner I use these settings when preparing bargraphs for publication. I’ve written the function offsetAxes, which removes the x- and y-axes lines from the origin to the first tick mark. Unlike seaborn’s ‘despine’, Matlab doesn’t support disconnecting the axes from the origin. Set(groot, 'DefaultAxesTickDirMode', 'manual') % set the tickdirs to go out - need this specific order % general graphics, this will apply to any figure you open I have this in my startup.m file, so I don’t have to retype these things whenever plotting a new figure. The settings here are best suited to subplot(4,4,x), which makes them about the right size for publishable-size figures when saved to an A4 pdf.

Update 2: for general data visualisation tips and tricks, check out this great blog by Gabriela Plucinska. The examples look great and might replace a lot of the manual code below – so if you’re starting with a new data viz project, definitely worth checking out! Update: Sebastian Lehmann pointed me to the gramm plotting library, which mimicks ggplot’s behaviour in Matlab. You can download the full Matlab tutorial script here, and run it for yourself rather than copying the parts. Of course, make sure that they are actually on your matlab path before starting. To make all the plots below, you will need: cbrewer, ploterr, suplabel, rddiffci, mysigstar, distributionPlot or my own adaptation violinPlot, and scatterHistDiff. PS2: many of the functions I use come from the file exchange, and can also be downloaded from Github (especially the plotting subfolder). If you’re still using an older version, please upgrade – it’s worth it! The figures shows were generated using 2015b on a Mac OS X El Capitan. PS1: This tutorial relies on Matlab’s new graphics engine that was introduced in version 2014b. Some final touches in Illustrator might not be possible to avoid, but this should get you quite far.

Here, I’ll make an overview of several types of plots I use a lot, and my strategies for making them look good. Chances that you’ll have to regenerate the figures at some point (because you decide to change one step somewhere in your analysis pipeline, say…), and by scripting the plots as much as possible you can replace your pdfs with an updated one with just one click.

Rather than prettifying all plots in Illustrator, I prefer doing as much as possible already in Matlab.
