CamDavidsonPilon / lifelines

Survival analysis in Python
lifelines.readthedocs.org
MIT License
2.32k stars 551 forks source link

How to label censored data on survival curves #1507

Closed realHongYuZhou closed 1 year ago

realHongYuZhou commented 1 year ago

lifelines is a great work that provides a lot of efficient features. But there is one thing I don't quite understand, how can I mark the censored data on the survival curve? I'm a novice and don't understand if I'm expressing myself clearly. As shown in the figure below, there are many short vertical lines on the survival curve, which represent censored data. How can I use lifelines to achieve this function? I hope you can provide me with a simple demo code, thank you. image

CamDavidsonPilon commented 1 year ago

Hi there, try something like:

kmf.plot_survival_function(show_censors=True, censor_styles={'ms': 6, 'marker': 'vline'})
realHongYuZhou commented 1 year ago

Thank you very much, but "vline" no use, I use '|' to replace, it is possible. Thank you for your answer and have a good life.