简体   繁体   English

如何在生存 plot 中设置自定义 x 轴间隔?

[英]How to set custom x axis interval in survival plot?

How to change the x axis intervals to 1,10,20...100 instead of 0,25,50,100?如何将 x 轴间隔更改为 1,10,20...100 而不是 0,25,50,100? I used folloing code to generate the survival plot我使用以下代码生成生存 plot

library(survminer)
library(tibble)
library(survival)
library(data.table)

#Create dataframe
datam = data.table(ID=1:100,
                  AGE= sample(20:90, size = 100, replace = T),
                  Cancer = sample(0:1, 100, replace = T),
                  Sex = rep(c("Male","Female"), 50))
surviv <- as_tibble(datam)

#Create sfit object
sfit <- survfit(Surv(AGE, Cancer)~Sex, data=surviv)

#Plot the survival analysis
ggsurvplot(sfit, conf.int = FALSE, legend = "bottom",
           palette = c("red", "blue"),legend.title="Sex",
           risk.table = TRUE, risk.table.col = "strata",
           legend.labs=c("Male", "Female"),
           xlim=c(0,100),xscale = 1,
           ggtheme = theme_survminer(),
           xlab = "Age at Diagnosis", size=1.5,
           ylab="Cumulative Risk", pval = FALSE,
           fun = "event")

生存情节

You can use the option break.x.by=10您可以使用选项break.x.by=10

ggsurvplot(sfit, conf.int = FALSE, legend = "bottom",
           palette = c("red", "blue"),legend.title="Sex",
           risk.table = TRUE, risk.table.col = "strata",
           legend.labs=c("Male", "Female"),
           xlim=c(0,100),xscale = 1,
           ggtheme = theme_survminer(),
           xlab = "Age at Diagnosis", size=1.5,
           ylab="Cumulative Risk", pval = FALSE,
           fun = "event", break.x.by=10)

生存情节

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM