Skip to content

Commit

Permalink
Merge pull request #187 from mingrisch/master
Browse files Browse the repository at this point in the history
Censor shape can be changed #186
  • Loading branch information
kassambara authored Apr 6, 2017
2 parents 21421fd + f52d29a commit b07181d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 3 additions & 1 deletion R/ggsurvplot.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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
Expand Down
8 changes: 7 additions & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b07181d

Please sign in to comment.