Kaplan–Meier survival curve maker with log-rank test
Paste one row per subject with the time, the event (1 = event, 0 = censored) and, optionally, a group. The tool draws the Kaplan–Meier (product-limit) survival curves with censoring ticks, a 95% confidence band and the number-at-risk table under the plot. It reports the median survival with its 95% confidence interval, Greenwood standard errors, the log-rank test P value between groups and the hazard ratio of two groups, and exports the figure as PNG or SVG and the tables as CSV.
- What it does
- Draws Kaplan–Meier survival curves from time and event data and compares groups with the log-rank test.
- Formula
- Example
- In the AML maintenance trial (11 maintained, 12 not), survival at 18 weeks in the maintained group is 10/11 × 9/10 × 7/8 = 0.716 (SE 0.140); median remission is 31 weeks vs 23 weeks, log-rank χ² = 3.40, P = 0.065.
Last updated
Loading Kaplan–Meier plot maker…
At a glance
| Input | Time, event (1/0) and optional group per subject, pasted from Excel |
|---|---|
| Estimate | Kaplan–Meier product limit with Greenwood SE |
| Confidence limits | Pointwise 95%: log–log (default), log or plain |
| Median | With 95% CI (Brookmeyer–Crowley, as R) |
| Comparison | Log-rank |
| Checked against | R survival (survfit, survdiff) and Python lifelines on the aml data |
| Output | Plot with number at risk as PNG or SVG; tables as CSV |
| Runs in | Your web browser; nothing is uploaded |
| Price | Free, no account needed |
What it does
How to use the kaplan–Meier plot maker
- Paste the dataOne subject per row: time, event (1 = death, relapse or other event; 0 = censored) and an optional group. Copy the columns straight from Excel.
- Choose the optionsKeep the log–log confidence limits, set the time unit and, if you like, a fixed end for the time axis.
- Read and exportRead the medians, the log-rank P value and the hazard ratio, then download the plot and the tables.
How it works
Product-limit estimate. At each distinct event time
Standard error and confidence band. The standard error is Greenwood’s formula (Greenwood 1926). The 95% limits are computed on the survfit(..., conf.type = "log-log") and lifelines. You can switch to the log scale (R’s default, conf.type = "log") or to plain limits
Median survival. The median is the first time quantile.survfit does; an upper limit that never crosses 0.5 is “not reached”.
Log-rank test. At each event time the expected number of events in group
Sources: Kaplan EL, Meier P. Nonparametric estimation from incomplete observations. J Am Stat Assoc 1958;53:457–481, doi:10.1080/01621459.1958.10501452. Brookmeyer R, Crowley J. A confidence interval for the median survival time. Biometrics 1982;38:29–41, doi:10.2307/2530286. Mantel N. Evaluation of survival data and two new rank order statistics arising in its consideration. Cancer Chemother Rep 1966;50:163–170. Greenwood M. The natural duration of cancer. Reports on Public Health and Medical Subjects No. 33. London: HMSO; 1926.
Worked example: the AML maintenance trial, checked against R
The built-in example is the acute myelogenous leukaemia trial distributed as the aml data set with R’s survival package: weeks in remission for 11 patients given maintenance chemotherapy and 12 who were not (a + marks a censored time).
- Maintained: 9, 13, 13+, 18, 23, 28+, 31, 34, 45+, 48, 161+
- Nonmaintained: 5, 5, 8, 8, 12, 16+, 23, 27, 30, 33, 43, 45
The product-limit estimate by hand for the maintained group:
| Week | At risk | Events | SE | 95% CI | ||
|---|---|---|---|---|---|---|
| 9 | 11 | 1 | 10/11 | 0.9091 | 0.0867 | 0.5081 to 0.9867 |
| 13 | 10 | 1 | 9/10 | 0.8182 | 0.1163 | 0.4474 to 0.9512 |
| 18 | 8 | 1 | 7/8 | 0.7159 | 0.1397 | 0.3502 to 0.8990 |
| 23 | 7 | 1 | 6/7 | 0.6136 | 0.1526 | 0.2658 to 0.8353 |
| 31 | 5 | 1 | 4/5 | 0.4909 | 0.1642 | 0.1673 to 0.7534 |
| 34 | 4 | 1 | 3/4 | 0.3682 | 0.1627 | 0.0928 to 0.6570 |
| 48 | 2 | 1 | 1/2 | 0.1841 | 0.1535 | 0.0117 to 0.5250 |
- Risk sets. At week 18 only 8 patients are at risk: two relapsed (weeks 9 and 13) and one was censored at week 13. The patient censored at 13 counts as at risk at the week-13 relapse.
- Multiply.
. - Greenwood.
, so . - Median. The curve first falls below 0.5 at week 31 (0.4909), so the median remission is 31 weeks; the lower log–log limit crosses 0.5 at week 13 and the upper never does, so the 95% CI is 13 weeks to not reached. For the nonmaintained group the median is 23 weeks (95% CI 5 to 33).
- Log-rank test. Observed and expected relapses are 7 and 10.69 (maintained) and 11 and 7.31 (nonmaintained), giving
with 1 df and P = 0.065. The O/E hazard ratio, maintained vs nonmaintained, is = 0.44 (95% CI 0.17 to 1.11).
These numbers match R exactly: survfit(Surv(time, status) ~ x, data = aml, conf.type = "log-log") gives the same survival, standard errors and limits (with R’s default log limits the first row reads 0.7541 to 1.000, which the tool also gives on the log setting), and survdiff gives
Frequently asked questions
How do I make a Kaplan–Meier curve?
For each subject record the time from the start (diagnosis, treatment, enrolment) to the event or to the last follow-up, and whether the event happened (1) or the subject was censored (0). Paste the columns here: the tool sorts the times, computes
How do I calculate Kaplan–Meier survival by hand?
Sort the times. At each time with an event, divide the number of events
What does censored mean in survival analysis?
A censored subject did not have the event while being followed: the study ended, they were lost to follow-up or they withdrew. All you know is that their time to event is longer than their follow-up time. Censored subjects count in the risk set until they leave and are drawn as tick marks on the curve.
How is median survival calculated?
It is the first time the Kaplan–Meier curve reaches 50% or below. If the curve never falls to 50%, the median is “not reached”. Its 95% confidence interval runs from where the lower to where the upper confidence curve crosses 50% (Brookmeyer and Crowley 1982).
How do I compare two survival curves?
Use the log-rank (Mantel–Cox) test, which compares the observed number of events in each group with the number expected if survival were the same, over the whole follow-up. Paste a group column and the tool reports
Which confidence interval should I use for a Kaplan–Meier curve?
The log–log (also called exponential Greenwood) interval is generally preferred because it stays between 0 and 1 and behaves better with small numbers at risk; it is what Python’s lifelines uses and R offers as conf.type = "log-log". R’s survfit uses the log scale by default, so state which one you used.
What does the number at risk table show?
For each time on the axis, how many subjects are still followed and event-free at that time. It tells readers how much data supports each part of the curve: the right-hand end, with few at risk, is the least certain.
How is the hazard ratio calculated from a log-rank test?
With two groups,
Link to this tool
Using it in a protocol, lab wiki or course page? Copy a link or citation.
<a href="https://www.labcanvas.com/tools/kaplan-meier-plot">Kaplan–Meier plot maker</a> (LabCanvas)LabCanvas. Kaplan–Meier plot maker [online tool]. https://www.labcanvas.com/tools/kaplan-meier-plotMake the survival figure for your paper
The LabCanvas Graph app draws Kaplan–Meier curves with censor ticks, runs the log-rank and Gehan–Wilcoxon tests and Cox regression, and styles the figure for publication. It opens with a survival example you can replace with your data.
Open the survival graph