Python Kaplan-Meier曲线未显示审查数据的刻度

Python Kaplan-Meier曲线未显示审查数据的刻度,python,survival-analysis,Python,Survival Analysis,我正在用python绘制Kaplan-Meier曲线。我的KMC很好,但它不会在我的数据中显示右删失案例的勾号。我尝试了很多来显示刻度,下面是我为此编写的代码。我不知道他们为什么不出现。如果有人能帮助我解决这个问题和解决方法,我将非常感激。这是我的数字 非常感谢 Python代码: def draw_KMC(): # In actual code file, here are some code lines before drawing the KMC but for the sake o

我正在用python绘制Kaplan-Meier曲线。我的KMC很好,但它不会在我的数据中显示右删失案例的勾号。我尝试了很多来显示刻度,下面是我为此编写的代码。我不知道他们为什么不出现。如果有人能帮助我解决这个问题和解决方法,我将非常感激。这是我的数字

非常感谢

Python代码:


def draw_KMC():
  # In actual code file, here are some code lines before drawing the KMC but for the sake of simplicity I am not adding those

  # ---- First Curve
  legend_label_1 = "Category A" 

  kmf_1 = KaplanMeierFitter()
  kmf_1.fit(durations = survival_times_A, event_observed=events_A, label=legend_label_A)


  # ---- Second Curve
  legend_label_2 = "Category B"
  kmf_2 = KaplanMeierFitter()
  kmf_2.fit(durations = survival_times_B, event_observed=events_B, label=legend_label_B)
  # ---- Third Curve
  legend_label_3 = "Category C"
  kmf_3 = KaplanMeierFitter()
  kmf_3.fit(durations = survival_times_C, event_observed=events_C, label=legend_label_C)

  ax = plt.subplot(111)
  plt.yticks(np.arange(0.0, 1.1, 0.1), ['0', '10', '20', '30', '40', '50', '60', '70',  
  '80', '90', '100'])
  kmf_1.plot(ax=ax,  show_censors=True,ci_show=False,censor_styles={"marker": "|", "ms": 
  6} )

  kmf_2.plot(ax=ax, show_censors=True,ci_show=False,censor_styles={"marker": "|", "ms": 
  6})
  kmf_3.plot(ax=ax,show_censors=True,ci_show=False,censor_styles={"marker": "|", "ms": 6})

  plt.xlabel('Months since the completion date', fontsize=12)
  plt.ylabel('Proportion of studies w.r.t categories (%)')
  plt.grid(True)
  from lifelines.plotting import add_at_risk_counts
  add_at_risk_counts(kmf_1, kmf_2,kmf_3, ax=ax)
  plt.show()

我甚至尝试用kmf.plot_survival_函数()替换kmf.plt(),但没有任何区别,也没有为经过审查的数据显示滴答声。我尝试在本地重新处理您的问题,但没有看到您观察到的行为。您能否尝试以下简化代码:


生存时间乘以生存时间=[10.9,15.5,20.3,25.6,30.8]
事件A=[真,假,假,真,真]
图例\u标签\u A=“测试”
#在实际的代码文件中,在绘制KMC之前,这里有一些代码行,但为了简单起见,我不添加这些代码行
#----第一条曲线
图例\u标签\u 1=“A类”
kmf_1=卡普兰梅尔菲特()
kmf_1.拟合(持续时间=存活时间\u次数\u A,观察到的事件\u A,标签=图例\u标签\u A)
ax=plt.子批次(111)
plt.yticks(np.arange(0.0,1.1,0.1),['0','10','20','30','40','50','60','70',',
'80', '90', '100'])
kmf_1.绘图(ax=ax,show_censors=True,ci_show=False,censor_style={“标记”:“o”,“ms”:
60} )
plt.xlabel(“自完成日期起的月份”,fontsize=12)
plt.ylabel(‘研究与r.t类别的比例(%))
plt.grid(真)
从lifelines.plotting导入添加风险计数
添加风险计数(kmf\u 1,ax=ax)
plt.show()
可能发生的情况是,你有这么多的数据点,审查标记正在“挤出”


另外,您能告诉我们您使用的是什么版本的
生命线吗?

另外,我对您的风险标签中
C类
令人恼火的错位有一个解决办法:非常感谢@Cam.Davidson.Pilon的回复。我已经尝试过简化的代码,但仍然看不到审查数据的任何标记。我的CSV文件包含数千个经过审查的数据值。生命线版本是0.26.0。我怎样才能显示勾号来表示经过审查的数据?这太奇怪了。。。您能为我们确认您的matplotlib版本吗?你能发布简化代码的绘图截图吗?matplotlib版本是3.4.2。我能在你的简化版本中看到点(我之前说过我不能,我当时做错了什么,对此表示歉意)。这是简化版的情节。因此,您的代码和设置很好。我怀疑这是matplotlib中的渲染问题。在您的原始代码中,尝试一些疯狂的东西,如
censor_styles={“marker”:“o”,“ms”:15}