Do not attempt to draw legend on survival curves if only one curve

This commit is contained in:
RunasSudo 2023-04-22 00:43:33 +10:00
parent 8238383edb
commit ae1a4cb5b8
Signed by: RunasSudo
GPG Key ID: 7234E476BF21C61A

View File

@ -80,7 +80,9 @@ def kaplanmeier(df, time, status, by=None, *, ci=True, transform_x=None, transfo
ax.set_ylabel('Survival probability ({:.0%} CI)'.format(1-config.alpha) if ci else 'Survival probability')
ax.set_xlim(left=0)
ax.set_ylim(0, 1)
ax.legend()
if by is not None:
ax.legend()
return fig, ax
@ -174,7 +176,9 @@ def turnbull(df, time_left, time_right, by=None, *, step_loc=0.5, transform_x=No
ax.set_ylabel('Survival probability')
ax.set_xlim(left=0)
ax.set_ylim(0, 1)
ax.legend()
if by is not None:
ax.legend()
return fig, ax