Draw survival curves beginning at time 0
This commit is contained in:
parent
f1e943ca89
commit
847ec85083
@ -89,8 +89,9 @@ def plot_survfunc_kaplanmeier(ax, time, status, ci, transform_x=None, transform_
|
||||
sf = sm.SurvfuncRight(time, status)
|
||||
|
||||
# Draw straight lines
|
||||
xpoints = sf.surv_times.repeat(2)[1:]
|
||||
ypoints = sf.surv_prob.repeat(2)[:-1]
|
||||
# np.concatenate(...) to force starting drawing from time 0, survival 100%
|
||||
xpoints = np.concatenate([[0], sf.surv_times]).repeat(2)[1:]
|
||||
ypoints = np.concatenate([[1], sf.surv_prob]).repeat(2)[:-1]
|
||||
handle = ax.plot(xpoints, ypoints)[0]
|
||||
|
||||
if transform_x:
|
||||
@ -106,8 +107,8 @@ def plot_survfunc_kaplanmeier(ax, time, status, ci, transform_x=None, transform_
|
||||
ci1 = sf.surv_prob + zstar * sf.surv_prob_se
|
||||
|
||||
# Plot confidence intervals
|
||||
ypoints0 = ci0.repeat(2)[:-1]
|
||||
ypoints1 = ci1.repeat(2)[:-1]
|
||||
ypoints0 = np.concatenate([[1], ci0]).repeat(2)[:-1]
|
||||
ypoints1 = np.concatenate([[1], ci1]).repeat(2)[:-1]
|
||||
|
||||
if transform_y:
|
||||
ypoints0 = transform_y(ypoints0)
|
||||
|
Loading…
Reference in New Issue
Block a user