plot_survival
plot_survival(
time
survival
*
censored=None
lower=None
upper=None
label=None
ax=None
show_censors=True
ci_alpha=0.25
**kwargs
)Draw a Kaplan-Meier curve and read it as a survival layer.
The curve is drawn as ax.step(time, survival, where="post") draws it, with the band as a shaded step and each censoring time as a tick on the curve. Several calls on one axes draw the arms of one chart, which a reader moves between with Up and Down.
Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| time | array_like |
The times at which the estimate is stated, strictly increasing, usually starting at 0. The estimate holds from each time until the next. | required |
| survival | array_like |
The survival probability from each time on. | required |
| censored | iterable of float | The times at which a subject left the study without the event happening. The curve does not step there; each is announced as censored, and the reader can move between them with the rotor. | None |
| lower | array_like |
The confidence band at each time, announced after the estimate. | None |
| upper | array_like |
The confidence band at each time, announced after the estimate. | None |
| label | str | The arm’s name, in the legend and in what is announced. | None |
| ax | Axes |
Where to draw; the current axes by default. | None |
| show_censors | bool | Whether to draw the censoring ticks. They are announced either way. | True |
| ci_alpha | float | The band’s opacity. | 0.25 |
| **kwargs | Any | Passed to ax.plot for the curve, such as color. |
{} |
Returns
| Name | Type | Description |
|---|---|---|
Axes |
The axes drawn on. |
Raises
| Name | Type | Description |
|---|---|---|
| ValueError | As :func:survival_points raises. |
Notes
survival is an experimental type; see docs/stability.qmd.
Examples
>>> import matplotlib.pyplot as plt
>>> import maidr
>>> fig, ax = plt.subplots()
>>> maidr.plot_survival(
... [0, 3, 6, 9], [1.0, 0.88, 0.71, 0.5], censored=[7], label="Control", ax=ax
... )
>>> maidr.show(fig)