Skip to content

Kaplan-Meier Survival Curves with Log-Rank Test

Paste a time column, an event column and an optional group column. You get step survival curves with censoring ticks, 95% confidence bands, the number at risk under the axis, median survival per group with its confidence interval, and the log-rank chi-square, degrees of freedom and p-value for the comparison.

Your data

Loading the figure…

SVG is vector — scale it to any size in Illustrator, Inkscape or LaTeX without losing quality, and edit the type. Use it unless a journal insists on raster.

Free downloads carry a small “made with assayplot.com” line along the bottom edge. Nothing else differs, and the figure on screen is never marked. Remove it

Options

Data

Estimate

All three use the Greenwood variance. The plain interval can run outside 0-1 and is clipped when it does.

Axes

Include the unit. Nothing in this tool converts one unit to another.

0 uses the longest follow-up in the data.

Figure

Three or more overlapping bands stop being readable; the default draws them only when they can be told apart.

Everything above is computed in this browser tab. Your data is not uploaded, and no request is made while you work.

What the tool does

It takes one row per subject — a time, and whether the event happened or the subject was censored — and draws the Kaplan-Meier estimate of the survival curve. Add a group column and it draws one curve per group, puts the number still at risk under the axis, and runs a log-rank test comparing them.

The curve is a step function and not a smooth one, deliberately: the estimate only changes at times when an event was actually observed, and drawing a smooth interpolation between those steps would imply information about the intervals that the data does not contain.

Censoring, and why it is the whole point

A subject is censored when the study ended, or they withdrew, or they were lost to follow-up, before the event happened. What is known about them is that they survived at least as long as their recorded time, and nothing more.

This is why survival analysis exists as its own subject. You cannot drop censored subjects — that biases the result towards whoever had events, badly. You cannot treat their last known time as an event time — that pretends something happened that did not. The product-limit estimator handles them correctly: a censored subject contributes to the risk set for every event up to their censoring time and then leaves without producing a step. The tick marks on the curve are where that happened.

The event column is the single most dangerous input in this tool, because both conventions exist in the wild: some datasets code 1 as "the event occurred" and some code 1 as "censored". Get it backwards and you get a plausible-looking curve that is completely wrong. The tool accepts many spellings, states on the figure which convention it applied, and has an explicit switch to flip it. Check that line before you use the figure.

Median survival, and when there is not one

The median is the earliest time at which the estimated survival drops to 0.5 or below. It is preferred over the mean because it can be read off a curve that has not finished: you only need half the subjects to have had events, whereas a mean needs all of them or an assumption about the tail.

If the curve never reaches 0.5 — which happens whenever fewer than half the subjects had events — there is no median, and the tool reports that rather than inventing one. "Not reached" is a real and publishable result. Its confidence interval is derived from the times at which the confidence band for the survival estimate contains 0.5, so a median can be estimable while one or both of its bounds is not.

The log-rank test, and what it does not tell you

The log-rank test asks whether the curves differ, and answers with a chi-square statistic, its degrees of freedom, and a p-value. It compares observed events with the number expected under the null hypothesis of identical survival, at every event time, weighting each time by the size of the risk set.

It gives no effect size. A significant p-value says the curves differ; it says nothing about by how much, or in which direction, or when. For that you need a hazard ratio, which requires a proportional-hazards model this tool does not fit.

It also assumes the difference between the groups points in one direction throughout. Two curves that cross — an early benefit that reverses, which is a real pattern in surgical and immunotherapy data — can produce a comfortably non-significant p-value while being obviously and importantly different, because the early and late contributions cancel in the sum. Always read the p-value next to the curves, never instead of them.

The Gehan-Breslow-Wilcoxon test is printed beside it. It is the same comparison with each event time weighted by how many subjects were still at risk then, so early differences count for more — the test to prefer when the curves are expected to separate early and converge later, and the one to avoid when the benefit only appears late. Which of the two applies is a decision about the biology, and it has to be made before either p-value is read: choosing the smaller of two numbers after seeing both is not a test. The methods page shows what each was validated against, including the fact that the variance used here is the one Prism and SAS use rather than the one in Gehan’s 1965 original.

The number-at-risk table

The row of counts under the axis is not decoration and most journals now require it. It is what lets a reader tell the difference between a curve that has genuinely plateaued and a curve whose tail is two remaining subjects. A survival estimate at a time when four people are left has enormous uncertainty and looks exactly as confident as one based on four hundred, unless the counts are printed.

Read the far right of the curve with the table in front of you. That is where over-interpretation happens.

Common questions

What format does my data need to be in?
One row per subject: a time column, an event column, and optionally a group column. Times can be days, weeks or months — the tool does not care and does not convert, so label the axis with whatever you used. The event column can be 1/0, yes/no, dead/alive, event/censored, or several other spellings.
Can I enter aggregated data instead of one row per subject?
No, and this is deliberate rather than an omission. The estimator needs the risk set at each event time, which cannot be recovered from grouped counts without assuming when within each interval the censoring occurred. A tool that accepted grouped data would have to make that assumption silently. If you only have a published curve and not the underlying data, what you want is a digitiser and a reconstruction method, not this.
Should I show the confidence bands?
For one or two curves, usually yes — they are the honest picture of how much the estimate is worth, especially in the tail. For three or more they overlap into an unreadable wash, and the number-at-risk table conveys the same caution more legibly. Note that the bands are pointwise: each is a 95% interval for the survival probability at that one time, not a 95% region containing the whole curve.
Which confidence interval transform is used?
The variance is Greenwood’s in every case. The interval is computed on a transformed scale and mapped back, which is what keeps it inside the range a probability can occupy — a plain interval of estimate ± 1.96 SE runs above 1 near the start of the curve and below 0 near the end. The figure states which transform was applied, and the methods page gives the formula.
Can it do a Cox model, or adjust for covariates?
No. This is an unadjusted comparison of whole groups: it knows nothing about age, stage or batch, and cannot separate a treatment effect from a difference in who ended up in which arm. If your groups differ in something that matters, you need a proportional-hazards model, and that means R or Stata.