Ron Bakker/MathLabHelp
Open MathLab ↗

Tutorial · Beginner · 6 min

Figures for papers and slides

Pick a figure style for a journal, thesis or slide deck, adjust fonts and colours the MATLAB way, and export a PDF or SVG at the right physical size.

  1. Choose a style

    Put style ieee (or paper, nature, thesis, slides, poster, minimal, grayscale) at the top. The preview then shows the exact page that will be exported: 3.5 inches wide for an IEEE column, in Times. Type styles in the console to list them all.

    style ieee
    x = linspace(0, 10, 200);
    plot(x, exp(-x/4).*sin(2*x), x, exp(-x/4), '--')
    xlabel('time (s)'), ylabel('amplitude')
    legend('signal', 'envelope')
    Try it ↗
  2. Black and white printing

    style grayscale draws every line in black or grey and tells them apart by dash pattern, so the figure still works on a photocopier.

    style grayscale
    x = linspace(0, 2*pi, 100);
    plot(x, sin(x), x, sin(2*x), x, sin(3*x))
    legend('n = 1', 'n = 2', 'n = 3'), title('Harmonics')
    Try it ↗
  3. Fine-tune it like MATLAB

    fontsize, fontname, colororder, theme and set(gca, …) work as in MATLAB. set(gcf, 'Units', 'centimeters', 'Position', [0 0 w h]) sets the export size.

    style paper
    bar([3 5 2 6; 4 4 3 5]')
    colororder('tableau'), fontsize(12), fontname('Georgia')
    set(gca, 'Box', 'off')
    set(gcf, 'Units', 'centimeters', 'Position', [0 0 12 7])
    title('Results by condition')
    Try it ↗
  4. Export from the script

    exportgraphics, saveas and print put a download button under the figure. PDF and PNG use the resolution you ask for; SVG is vector. The Export menu offers the same, with size presets.

    style nature
    t = linspace(0, 1, 300);
    plot(t, sin(2*pi*5*t).*exp(-3*t))
    xlabel('t (s)'), ylabel('V')
    exportgraphics(gcf, 'figure1.pdf', 'Resolution', 600)
    exportgraphics(gcf, 'figure1.svg', 'ContentType', 'vector')
    Try it ↗

    Tip: For LaTeX use the PDF with \includegraphics; for Word, the 600 dpi PNG or the PDF.