Skip to content

Cancer Journal Plot Style Guide

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.

Apply these standards whenever producing a Kaplan–Meier survival figure for journal submission. They reflect the house rules of Nature Cancer, Cancer Cell, and JCO: compact, print-safe, and font-embedded.

rcParams — apply at the top of every 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,
})

The font sizes (7 pt labels, 6 pt ticks) and line widths (0.75 pt) differ deliberately from David's personal presentation style — journals shrink figures to column width, so anything larger prints as a blob.

Figure size

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

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

Color palette

Controls get dark neutrals with broken line styles so the figure survives greyscale printing. Treatments get colors with solid lines.

Group role Hex Line style
Control 1 #333333 dashed (0,(4,2))
Control 2 #888888 dotted (0,(2,2))
Treatment 1 #C0392B (deep red) solid
Treatment 2 #2471A3 (deep blue) solid

For more than two treatment groups, extend with #27AE60 (green) and #8E44AD (purple), always solid.

KM curves — use lifelines

from lifelines import KaplanMeierFitter

kmf = KaplanMeierFitter()
kmf.fit(T, E, label=name)
kmf.plot_survival_function(
    ax=ax,
    ci_show=True,          # 95% CI bands — expected by reviewers
    ci_alpha=0.12,
    color=COLORS[name],
    linestyle=LINESTYLES[name],
    linewidth=0.75,
    show_censors=True,
    censor_styles={'marker': '|', 'ms': 4, 'mew': 0.75},
    label=name,
)

X-axis

Trim to just past the last observed time point — never pad to a round number.

last_event = max(T.max() for T, _ in groups.values())
ax.set_xlim(0, last_event + 1)
ax.xaxis.set_major_locator(ticker.MultipleLocator(10))
ax.xaxis.set_minor_locator(ticker.MultipleLocator(5))

Spines and ticks

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

Legend

Upper right, thin grey box (aids readability in print — do not use frameon=False here even though David's personal style does).

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)

p-value annotation

Log-rank test results go in the bottom-left corner as a small text box. Place it there — not mid-plot where it would obscure curves.

from lifelines.statistics import logrank_test

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

p_lines = [f"{g1} vs {g2}: {fmt_p(p)}" for (g1, g2), p in p_results.items()]

ax.text(0.03, 0.03, '\n'.join(p_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))

Number-at-risk table

Do not include in the main figure. Supply it in supplementary material if required. Removing it avoids layout complexity and the table can always be added to the supplement via lifelines.plotting.add_at_risk_counts.

Saving

Always save both formats — PNG for review, PDF for journal submission.

plt.tight_layout()
plt.savefig('km_curves_journal.png', dpi=300, bbox_inches='tight')
plt.savefig('km_curves_journal.pdf', bbox_inches='tight')

Quick checklist

Before saving, verify: - [ ] Figure 88 × 70 mm - [ ] Arial 7 pt labels, 6 pt ticks - [ ] 95% CI bands shown - [ ] Censoring marks on curves (| ticks) - [ ] X-axis trimmed to last event + 1 (not a round number) - [ ] Legend upper right with thin grey box - [ ] p-values bottom left, not obscuring data - [ ] Saved as PNG (300 dpi) and PDF - [ ] pdf.fonttype = 42 in rcParams