library('rmda')
library('ggDCA')
library('ggplot2')
library('rms')
library('caret')
library('survival')
library('survminer')
library('xlsx')
data1 <- read.xlsx('D:/desktop/temp_CHD.xlsx',1)
cph1 <- cph(Surv(survival_30,status_30) ~
ad_type
+ gender + age + race
+ af + ckd + copd + dm + hl + ht
+ oldmi + precar + plt + wbc
+ crea + hemoglo + hemato
+ glu,data = data1)
cph2 <- cph(Surv(survival_30,status_30) ~
gender + age + race,data = data1)
dca_cph <- dca(cph1,cph2,model.names = c("Full model", "Basic model"))
ggplot(dca_cph,linetype = c(1,1,2,2),
color = c('#0070b9','#ec008c','grey','black'))
# +xlim(0.1, 0.5)
# +ylim(-0.1,0.4)
巨佬们帮忙瞧瞧,为什么粉线看起来不全啊?粉线单独跑也是不全的qaq
引用 皆我百晓生 小程序回复内容作答:
根据您提供的代码,粉线不完整的问题可能是由于缺少一些绘图参数所引起的。您可以尝试添加以下代码来修改绘图参数,以确保粉线完整显示:
ggplot(dca_cph, linetype = c(1, 1, 2, 2), color = c('#0070b9', '#ec008c', 'grey', 'black')) +
xlim(0, 0.5) +
ylim(-0.1, 0.4) +
guides(linetype = guide_legend(override.aes = list(size = 1.5, color = c('#0070b9', '#ec008c', '#ec008c', 'black'))))
在这个例子中,我们使用xlim
和ylim
函数分别设置x轴和y轴的坐标范围,以确保粉线完整显示。我们还使用guides
函数设置图例的样式,以使其与线条颜色一致。
另外,您的最后一行代码img
无法运行,建议删除或修改它以避免错误。
【相关推荐】