diff --git a/R/ggsurvplot.R b/R/ggsurvplot.R index 5718d2a..931ba28 100644 --- a/R/ggsurvplot.R +++ b/R/ggsurvplot.R @@ -48,6 +48,7 @@ #'@param conf.int.style confidence interval style. Allowed values include #' c("ribbon", "step"). #'@param censor logical value. If TRUE, censors will be drawn. +#'@param censor.shape character or numeric value specifying the point shape of censored subjects. Default is "+" (3), a sensible choice is "|" (124). #'@param pval logical value. If TRUE, the p-value is added on the plot. #'@param pval.size numeric value specifying the p-value text size. Default is 5. #'@param pval.coord numeric vector, of length 2, specifying the x and y @@ -281,6 +282,7 @@ ggsurvplot <- function(fit, data = NULL, fun = NULL, surv.scale = c("default", "percent"), xscale = 1, conf.int = FALSE, conf.int.fill = "gray", conf.int.style = "ribbon", censor = TRUE, + censor.shape = "+", pval = FALSE, pval.size = 5, pval.coord = c(NULL, NULL), pval.method = FALSE, pval.method.size = pval.size, pval.method.coord = c(NULL, NULL), log.rank.weights = c("survdiff", "1", "n", "sqrtN", "S1", "S2", "FH_p=1_q=1"), @@ -453,7 +455,7 @@ ggsurvplot <- function(fit, data = NULL, fun = NULL, # Add cencored if (censor & any(d$n.censor >= 1)) { p <- p + ggpubr::geom_exec(ggplot2::geom_point, data = d[d$n.censor > 0, , drop = FALSE], - colour = surv.color, size = size*4.5, shape = "+") + colour = surv.color, size = size*4.5, shape = censor.shape) } # Add pvalue diff --git a/README.Rmd b/README.Rmd index 287de5a..536e743 100644 --- a/README.Rmd +++ b/README.Rmd @@ -145,8 +145,14 @@ fit <- survfit(Surv(time, status) ~ sex, data = lung) ```{r ggplot2-basic-survival-plot, fig.height = 4, fig.width = 5} ggsurvplot(fit, data = lung) ``` + +Censor shape can be changed as follow: + +```{r ggplot2-basic-survival-plot-censor, fig.height = 4, fig.width = 5} +ggsurvplot(fit, data = lung, censor.shape="|") +``` - + ### Customized survival curves diff --git a/tools/README-ggplot2-basic-survival-plot-censor-1.png b/tools/README-ggplot2-basic-survival-plot-censor-1.png new file mode 100644 index 0000000..5f6db0d Binary files /dev/null and b/tools/README-ggplot2-basic-survival-plot-censor-1.png differ