How to hide confidence interval in lifelines Kaplan-Meier plots
Using the lifelines library, you can easily plot Kaplan-Meier plots, e.g. as seen in our previous post Minimal Python Kaplan-Meier Plot example:
from lifelines.datasets import load_leukemia
from lifelines import KaplanMeierFitter
df = load_leukemia()
kmf = KaplanMeierFitter()
kmf.fit(df['t'], df['Rx']) # t = Timepoints, Rx: 0=censored, 1=event
kmf.plot()
What if you just want to show the dark blue curve and hide the light-blue confidence interval?
Easy: Just use km.plot(ci_show=False)
. ci
in ci_show
means confidence interval. Example:
from lifelines.datasets import load_leukemia
from lifelines import KaplanMeierFitter
df = load_leukemia()
kmf = KaplanMeierFitter()
kmf.fit(df['t'], df['Rx']) # t = Timepoints, Rx: 0=censored, 1=event
kmf.plot(ci_show=False)