njab.plotting package

njab.plotting package#

Matplotlib functionality for custom plots.

njab.plotting.compare_km_curves(time: Series, y: Series, pred: Series, ax: Axes | None = None, ylim: tuple[int] = (0, 1), xlim: tuple[int] = (0, 180), xlabel: str | None = None, ylabel: str | None = None, add_risk_counts=False) Axes[source]#

Compare Kaplan-Meier curves for two groups (e.g. based on binary prediction)

Parameters:
  • time (pd.Series) – Time to event variable

  • y (pd.Series) – event variable

  • pred (pd.Series) – mask for two groups, e.g. predictions

  • ax (Axes, optional) – matplotlib Axes object, by default None

  • ylim (tuple[int], optional) – y-axis bounds, by default (0, 1)

  • xlim (tuple[int], optional) – time-axis bounds, by default (0, 730)

  • xlabel (str, optional) – time-axis label, by default None

  • ylabel (str, optional) – y-axis label, by default None

Returns:

Axes object, KaplanMeierFitter for predited as 0, KaplanMeierFitter for predicted as 1

Return type:

Axes, KaplanMeierFitter, KaplanMeierFitter

njab.plotting.plot_lifelines(obs: DataFrame, ax=None, start_col='DateDiagnose', end_col='DateDeath', status_col='dead') Axes[source]#

Plot a lifeline for each observation.

Submodules#