How to make a Kaplan–Meier plot
- Paste one row per participant from Excel or your statistics package, or drop an .xlsx or CSV file. The Excel template has the right columns.
- Check the columns (time, status, group) and which status value means an event.
- Put the reference group first in the group order; hazard ratios compare every other group with it.
- Choose what to show: number at risk (with events for the KMunicate style), censoring marks, confidence bands, medians, log-rank P and hazard ratio.
- Apply your journal’s rules and export a vector PDF or SVG, or PNG/TIFF up to 1200 dpi. The methods text and an R script are one click away.
Reading a Kaplan–Meier plot
- Each step down is one or more events; tick marks are censored participants, who left follow-up without the event.
- The curve is less certain where few participants are left: check the number at risk before reading the tail.
- The log-rank test compares the whole curves; the hazard ratio assumes proportional hazards, which crossing curves call into question.
- For time-to-event outcomes in trials, report the flow of participants with a CONSORT diagram; pooled hazard ratios from several studies go in a forest plot.
Data format
| Time | Event | Group |
|---|---|---|
| 306 | 1 | Male |
| 1010 | 0 | Female |
Frequently asked questions
What data do I need?
One row per participant: the follow-up time (until the event, or until last contact for censored participants), a status column that says whether the event happened, and optionally a group. Status can be 0/1, 1/2 (as in R, where 2 is the event) or words such as dead/alive or yes/no; you choose which value means the event. Rows with a missing or negative time, no status or (when you compare groups) no group are left out and counted in a message.
How are the curves, confidence intervals and medians calculated?
Survival is estimated with the Kaplan–Meier product-limit method. The 95% confidence intervals use Greenwood’s variance on the log scale, the default of R’s survfit. The median is the first time the curve reaches 0.5 or below, with its confidence interval from where the confidence limits cross 0.5; if a curve never drops to 0.5, the median is reported as “not reached”. All values match R’s survival package on its published example datasets.
Which tests are reported?
The log-rank test compares the groups (with k − 1 degrees of freedom for k groups). Hazard ratios with 95% confidence intervals come from a Cox proportional hazards model with the Efron method for tied times, the default in R’s coxph, with the first group in the list as the reference. Change the order of the groups to change the reference.
Why show the number at risk?
The curves become unreliable when few participants remain, and readers cannot see that from the curve alone. Most journals and the KMunicate study (Morris et al., BMJ Open 2019) recommend a number-at-risk table under the time axis; the KMunicate style adds the cumulative number of events in brackets.
Is my patient data uploaded?
No. The file is read and analysed in your browser; nothing is sent to a server. That matters for patient-level data, which many online survival tools upload for processing.
Can I reproduce the analysis in R?
Yes. “R code” gives a script with your data that runs survfit, survdiff and coxph from the survival package, which is installed with R. For a ggplot figure with a risk table in R, the survminer package offers ggsurvplot.