Skip to content

Publication-Ready Figures

Most analysis ends in a figure, and a small set of figures does most of the work in a biology methods section. A box plot with a p-value. A survival curve. A clustered heatmap. This section builds each one twice, in R and in Python, from the same tidy data, with the right statistical test wired into the plot rather than bolted on after.

The approach is the one a bench scientist recognizes from GraphPad Prism: pick the test the data supports, draw the comparison, and put the result on the figure where a reviewer will see it. The difference is that here the figure, its code, and its numbers are all reproducible. Every figure on these pages is produced by a real run in a pinned container, the same one for both languages.

Figure What it compares Test on the plot
Two-group comparison one outcome, two groups t-test or Mann-Whitney, chosen from the data
Multi-group comparison one outcome, three or more groups one-way ANOVA + Tukey HSD
Factorial ANOVA one outcome, two crossed factors Type II ANOVA with interaction
Kaplan-Meier survival time to event, two arms log-rank
Cox forest plot adjusted hazard per covariate Cox proportional hazards
Clustered heatmap expression, features by samples hierarchical clustering

Each page shows the same figure in both languages, in synced tabs, so you can read whichever you know and see its twin.

  • R uses ggpubr and rstatix for the comparison plots, survminer for survival, and ComplexHeatmap for the heatmap. All build on ggplot2.
  • Python uses seaborn with statannotations and pingouin for the comparison plots, lifelines for survival, and seaborn.clustermap for the heatmap.

Where both languages compute the same statistic, they agree: the two-group t-test matches to nine significant figures, the ANOVA and the log-rank agree to the digit. The figures themselves are drawn each library’s idiomatic way, so they look alike without being pixel-identical. The runnable code and fixtures for every page live in the companion code repo under guides/figures/.