|
40 | 40 | #' @param nejm.infigure.ratioh Ratio of infigure height to total height, Default = 0.5 |
41 | 41 | #' @param nejm.infigure.ylim y-axis limit of infigure, Default = c(0,1) |
42 | 42 | #' @param surv.by breaks unit in y-axis, default = NULL(ggplot default) |
| 43 | +#' @param nejm.surv.by breaks unit in y-axis in nejm figure, default = NULL(ggplot default) |
43 | 44 | #' @param hr logical: add the hazard ratio to the plot? |
44 | 45 | #' @param hr.size numeric value specifying the HR text size. Default is 5. |
45 | 46 | #' @param hr.coord numeric vector, of length 2, specifying the x and y coordinates of the p-value. Default values are NULL |
@@ -130,6 +131,7 @@ jskm <- function(sfit, |
130 | 131 | nejm.infigure.ratioh = 0.5, |
131 | 132 | nejm.infigure.ylim = c(0, 1), |
132 | 133 | surv.by = NULL, |
| 134 | + nejm.surv.by = NULL, |
133 | 135 | hr = FALSE, |
134 | 136 | hr.size = 5, |
135 | 137 | hr.coord = c(NULL, NULL), |
@@ -984,10 +986,20 @@ jskm <- function(sfit, |
984 | 986 | ####################### |
985 | 987 |
|
986 | 988 | if (!is.null(theme) && theme == "nejm") { |
987 | | - p2 <- p1 + coord_cartesian(ylim = nejm.infigure.ylim) + theme( |
988 | | - axis.title.x = element_blank(), axis.title.y = element_blank(), |
989 | | - axis.text = element_text(size = 10 * nejm.infigure.ratiow), |
990 | | - ) + guides(colour = "none", linetype = "none") + scale_y_continuous(limits = nejm.infigure.ylim, breaks = waiver(), labels = scale_labels) |
| 989 | + |
| 990 | + if(!is.null(nejm.surv.by)){ |
| 991 | + p2 <- p1 + coord_cartesian(ylim = nejm.infigure.ylim) + theme( |
| 992 | + axis.title.x = element_blank(), axis.title.y = element_blank(), |
| 993 | + axis.text = element_text(size = 10 * nejm.infigure.ratiow), |
| 994 | + ) + guides(colour = "none", linetype = "none") + scale_y_continuous(limits = nejm.infigure.ylim, breaks = seq(nejm.infigure.ylim[1], nejm.infigure.ylim[2], by = nejm.surv.by), labels = scale_labels) |
| 995 | + }else{ |
| 996 | + p2 <- p1 + coord_cartesian(ylim = nejm.infigure.ylim) + theme( |
| 997 | + axis.title.x = element_blank(), axis.title.y = element_blank(), |
| 998 | + axis.text = element_text(size = 10 * nejm.infigure.ratiow), |
| 999 | + ) + guides(colour = "none", linetype = "none") + scale_y_continuous(limits = nejm.infigure.ylim, breaks = waiver(), labels = scale_labels) |
| 1000 | + } |
| 1001 | + |
| 1002 | + |
991 | 1003 | p <- p + patchwork::inset_element(p2, 1 - nejm.infigure.ratiow, 1 - nejm.infigure.ratioh, 1, 1, align_to = "panel") |
992 | 1004 | } |
993 | 1005 |
|
|
0 commit comments