depictr.survival_plot#

depictr.survival_plot(time, event, group=None, conf_level=0.95, risk_table=False, legend_inside=False, title=None, x_lab='Time', y_lab='Survival probability')#

Kaplan-Meier survival curves, optionally by group, with a log-rank test.

Parameters:
  • time (array-like) – Follow-up times.

  • event (array-like) – Event indicator (1 = event, 0 = censored).

  • group (array-like, optional) – Group label per observation; one curve per group, plus a log-rank test of the difference.

  • conf_level (float) – Confidence level (reserved for the confidence band; the step curve is drawn now, the band is planned).

  • risk_table (bool) – Add a number-at-risk table as a thin strip beneath the curves.

  • legend_inside (bool) – When True (and there are groups), place the group legend inside the panel rather than in a right-hand margin: the bottom-left for a plain curve, or the top-right when a risk table occupies the bottom strip. Either corner is one a descending survival curve leaves empty.

  • title (str, optional)

  • x_lab (str) – Axis labels.

  • y_lab (str) – Axis labels.

Returns:

The plot carries .at_risk (a DataFrame of number-at-risk counts) and, when grouped, .logrank_p and .logrank_stat.

Return type:

plotnine.ggplot