Allow passing own fig, ax to yli.kaplanmeier

This commit is contained in:
RunasSudo 2023-10-20 21:11:35 +11:00
parent 26a6766f0e
commit 675422246f
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A
1 changed files with 3 additions and 2 deletions

View File

@ -22,7 +22,7 @@ from .config import config
from .sig_tests import ChiSquaredResult
from .utils import Estimate, check_nan
def kaplanmeier(df, time, status, by=None, *, ci=True, transform_x=None, transform_y=None, nan_policy='warn'):
def kaplanmeier(df, time, status, by=None, *, ci=True, transform_x=None, transform_y=None, nan_policy='warn', fig=None, ax=None):
"""
Generate a KaplanMeier plot
@ -59,7 +59,8 @@ def kaplanmeier(df, time, status, by=None, *, ci=True, transform_x=None, transfo
# Covert timedelta to numeric
df, time_units = survtime_to_numeric(df, time)
fig, ax = plt.subplots()
if ax is None:
fig, ax = plt.subplots()
if by is not None:
# Group by independent variable