Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Censor shape can be changed #186 #187

Merged
merged 7 commits into from Apr 6, 2017
View
@@ -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
View
@@ -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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.