Skip to content

C4. Multi-panel figures ​

Goal: one figure of several panels across the page, labelled (a), (b), (c), in the paper's font.

gnuplot
set terminal pdfcairo size double theme paper serif
set output 'pc04.pdf'
set multiplot layout 1,3 title "Second-order response"
set logscale x
set xlabel "ω / ω_n"
set title "(a) gain"
plot [0.1:10] for [z in "0.1 0.3 1"] 1/sqrt((1-x**2)**2 + (2*z*x)**2) title "ζ = ".z
set title "(b) phase"
plot [0.1:10] for [z in "0.1 0.3 1"] 180/pi*atan2(2*z*x, 1-x**2) title "ζ = ".z
unset logscale x
set title "(c) step"
set xlabel "ω_n t"
plot [0:20] for [z in "0.1 0.3"] 1 - exp(-z*x)*cos(sqrt(1-z**2)*x) title "ζ = ".z
unset multiplot
pc04
open SVG ↗

pc04.pdf spans the page (size double, 17.8 x 8 cm), its texts in Latin Modern Roman (theme paper serif): the figure* environment of a two-column paper takes it as it is.

Why it works ​

  • set multiplot layout 1,3 title "..." divides the page as gnuplot does: the title's band on top (its lines a character height each), then three cells of equal width; each panel's own title takes gnuplot's room above its plot.
  • The panels share the page's font and sizes: one set terminal sets them all.
  • plot for [z in "0.1 0.3 1"] draws one curve per value, "ζ = ".z its key entry.

Try this ​

  • set multiplot layout 2,2: four panels in a size 17.8cm,12cm page.
  • set key off in all panels but the first: one key for the figure.

Pitfalls ​

  • Panels placed by set origin and set size under a multiplot title start below foresight's title band, where gnuplot draws them from the page's top (a documented difference: see Comparison).
  • Each panel measures its own margins: give the panels the same tick label widths (set format y "%.1f") to align their plot areas.

Released under the GPL v3, BSD 2-Clause, BSD 3-Clause or MIT License.