A2. Styles and the key
Goal: three residuals on one plot, told apart at a glance, also printed in gray.
fortran
call fig%plot(it, rho, title='continuity', lw=2.0_R8P)
call fig%plot(it, mom, title='momentum', dt=2_I4P)
call fig%plot(it(::8), energy(::8), title='energy', with='linespoints', pt=7_I4P, lc='#e51e10')
call fig%set_key(position='outside right top', box=.true.)Why it works
- Each series takes the next of gnuplot's linetype colors, unless
lcsets one (any SVG color:'#e51e10','red'). lwis the line width [px],dtthe dash type (1 solid, 2–5 dash patterns): a dash pattern survives a gray printer, a color does not.with='linespoints'draws the points on the line;with='points'the points only.ptpicks the point type, as gnuplot: 1 plus, 2 cross, 4 square, 6 circle, 8 triangle, … the odd ones from 5 filled;psscales it.it(::8)plots every 8th iteration: a sparse series reads better with markers.
The key
set_key takes gnuplot's position words: left, right, center, top, bottom, and outside to move it out of the plot, which shrinks to make room. box=.true. draws a frame. 'below' and 'above' put the entries in a row under or over the plot; set_key(.false.) hides it. An empty title keeps a series out of the key.
Try this
with='steps': a residual logged once per iteration is a staircase, not a slope.call fig%set_theme('paper'): the Okabe-Ito colors, distinct for color-blind readers and in gray.call fig%set_key(position='bottom left', box=.true.), thenposition='outside': watch the plot shrink.
Pitfalls
- A color and a dash type set on one series do not carry to the next: each
plotcall takes its own. - Past a handful of series a plot stops being readable whatever the styles: split it into panels (A6 and the multiplot).
Reference: Fortran Library, point types. Next: A3. Axes.