Skip to content

The journal-figure skill

A Skill file

A Skill is a Markdown file an agent loads when a task matches its description — knowledge about how you want a job done, written once. It is reproduced here as it stands in the course repository, so paths such as Attachments/ refer to that repo.


name: journal-figure description: > Style standard for matplotlib figures destined for journal submission — compact, print-safe, greyscale-safe and font-embedded. Use this skill whenever asked to make, redraw or clean up a figure for a paper, a submission or a supplement, even if the request is only "plot this" or "make a figure of the results". Not for presentation graphics: slides use the slide-deck skill, which has different sizes for a reason.


Journal figure standard

A figure for a paper is not a figure for a screen. It will be printed at column width, possibly in greyscale, and a publisher's typesetter will want the fonts embedded. Everything below follows from those three facts.

The Kaplan–Meier version of this — the one lesson 1.2 describes creating, with the survival-specific choices spelled out — is in Additional material/Skills/cancer-journal-plot-SKILL.md, and Attachments/survival_analysis.py is it in use. Read them for a worked example.

rcParams — at the top of every figure script

mm = 1 / 25.4  # mm → inches
plt.rcParams.update({
    'font.family':       'sans-serif',
    'font.sans-serif':   ['Arial', 'Helvetica', 'DejaVu Sans'],
    'font.size':         7,
    'axes.linewidth':    0.5,
    'xtick.major.width': 0.5,
    'ytick.major.width': 0.5,
    'xtick.major.size':  3,
    'ytick.major.size':  3,
    'xtick.minor.width': 0.3,
    'xtick.minor.size':  1.5,
    'lines.linewidth':   0.75,
    'pdf.fonttype':      42,   # TrueType embedding — required by most publishers
    'ps.fonttype':       42,
})

pdf.fonttype: 42 is the one that gets a submission bounced if it is missing: without it matplotlib emits Type 3 fonts, which many publishers reject outright.

Size

Single column: 88 × 70 mm. Adjust the height if the content is cramped; keep the width at 88 mm unless the journal explicitly allows 1.5-column (about 120 mm) or double-column (about 180 mm).

fig, ax = plt.subplots(figsize=(88*mm, 70*mm))

Design at that size from the start. A figure drawn large and shrunk to fit prints as a blob — this is why the 7 pt labels and 0.75 pt lines here look wrong on screen and right on paper.

Colour, paired with linestyle

Never let colour be the only thing distinguishing two series. Print and photocopying flatten it, and roughly one reader in twelve cannot separate red from green. Pair every colour with a linestyle or marker, so the figure survives in greyscale.

The convention used in this course: reference or control conditions get dark neutrals with broken lines; the things being tested get colour with solid lines.

Role Hex Line style
Control / reference 1 #333333 dashed (0,(4,2))
Control / reference 2 #888888 dotted (0,(2,2))
Condition 1 #C0392B (deep red) solid
Condition 2 #2471A3 (deep blue) solid
Condition 3 #27AE60 (green) solid
Condition 4 #8E44AD (purple) solid

Check it: convert the saved PNG to greyscale and confirm you can still tell the series apart.

Axes

Trim the limits to just past the data — never pad out to a round number. Half an empty panel is the most common thing wrong with a first-draft figure, and reviewers read the whitespace as sloppiness.

ax.set_xlim(0, last_observation + 1)
ax.xaxis.set_major_locator(ticker.MultipleLocator(10))
ax.xaxis.set_minor_locator(ticker.MultipleLocator(5))

Drop the top and right spines. Small ticks, tight padding.

ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.tick_params(labelsize=6, length=3, width=0.5, pad=2)

Label both axes with units. Time (days), not t.

Legend

Inside the axes wherever there is room — usually upper right — with a thin grey box. A box helps in print, where the legend sits over gridless white and can read as floating text.

leg = ax.legend(fontsize=6, loc='upper right', frameon=True,
                handlelength=1.8, handletextpad=0.4, borderpad=0.4,
                edgecolor='#cccccc')
leg.get_frame().set_linewidth(0.4)

Statistics on the figure

Test results go in a corner, as a small boxed annotation — typically bottom left. Not mid-panel, where they cover the data.

def fmt_p(p):
    return 'p < 0.001' if p < 0.001 else f'p = {p:.3f}'

ax.text(0.03, 0.03, '\n'.join(lines),
        transform=ax.transAxes, fontsize=5.5, va='bottom', ha='left',
        linespacing=1.5,
        bbox=dict(boxstyle='round,pad=0.3', facecolor='white',
                  edgecolor='#cccccc', linewidth=0.4))

Report the test, not just the verdict. If there is a multiple-comparison correction, say what the corrected threshold is rather than converting p-values into stars.

Uncertainty

Show it. Confidence bands, error bars or individual points, whichever suits the data — at small n, plotting the points beats any summary of them. A clean mean-only curve at n = 5 overstates what the data support, and a reviewer will say so.

Saving

Both formats, always: PNG to look at and circulate, PDF for submission.

plt.tight_layout()
plt.savefig(os.path.join(DATA_DIR, 'figure.png'), dpi=300, bbox_inches='tight')
plt.savefig(os.path.join(DATA_DIR, 'figure.pdf'), bbox_inches='tight')

Resolve DATA_DIR from __file__, and save into Attachments/ — not the working directory.

Then look at it

Open the PNG and look at it before saying the figure is done. Overlapping labels, a clipped legend, a stray tick — these are obvious in the image and invisible in the code. Rendering and inspecting is the loop that makes this worth doing with an agent at all.

Checklist

  • [ ] 88 mm wide (or a width the journal allows), designed at that size
  • [ ] 7 pt labels, 6 pt ticks, 0.75 pt lines
  • [ ] pdf.fonttype = 42
  • [ ] Every series distinguishable in greyscale
  • [ ] Axis limits trimmed to the data, not to round numbers
  • [ ] Both axes labelled with units
  • [ ] Top and right spines removed
  • [ ] Uncertainty shown
  • [ ] Statistics in a corner, not over the data
  • [ ] Saved as PNG at 300 dpi and PDF, into Attachments/
  • [ ] Rendered image actually looked at