plot_kaplan_meier

Note

This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the Habitat Guide and Python API guide (v2.0) for usage.

plot_kaplan_meier(time: ndarray, event: ndarray, group: ndarray | None = None, *, group_names: Sequence[str] | None = None, ci: bool = True, show_censoring: bool = True, risk_table: bool = True, log_rank: bool = True, title: str = 'Kaplan-Meier', time_label: str = 'Time', probability_label: str = 'Survival probability')[source]

Kaplan-Meier curves, optionally stratified, with a numbers-at-risk table.

Parameters:
  • time – Observed follow-up durations.

  • event – Event indicators, True for observed events.

  • group – Optional per-row stratum labels for 2+ KM curves; None draws a single cohort curve.

  • group_names – Display names for the strata, in sorted-label order; defaults to the labels themselves. Sanitised to ASCII.

  • ci – Draw the pointwise confidence band.

  • show_censoring – Mark censored observations on the curve.

  • risk_table – Append a numbers-at-risk table beneath the axis.

  • log_rank – Annotate the log-rank p-value (only with 2 strata).

  • title – Figure title (sanitised).

  • time_label – X-axis label (sanitised).

  • probability_label – Y-axis label (sanitised).

Returns:

The matplotlib Figure.