diff --git a/R/jskm.R b/R/jskm.R index 1f2ce2f..d8518b4 100644 --- a/R/jskm.R +++ b/R/jskm.R @@ -380,20 +380,22 @@ jskm <- function(sfit, geom_step(data = subset(df, time >= cut.landmark), linewidth = linewidth) + geom_step(data = subset(df, time < cut.landmark), linewidth = linewidth) } - brewer.palette <- c("BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", "RdYlBu", "RdYlGn", "Spectral", "Accent", "Dark2", "Paired", "Pastel1", "Pastel2", - "Set1", "Set2", "Set3", "Blues", "BuGn", "BuPu", "GnBu", "Greens", "Greys", "Oranges", "OrRd", "PuBu", "PuBuGn", "PuRd", "Purples", - "RdPu", "Reds", "YlGn", "YlGnBu", "YlOrBr", "YlOrRd") - + brewer.palette <- c( + "BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", "RdYlBu", "RdYlGn", "Spectral", "Accent", "Dark2", "Paired", "Pastel1", "Pastel2", + "Set1", "Set2", "Set3", "Blues", "BuGn", "BuPu", "GnBu", "Greens", "Greys", "Oranges", "OrRd", "PuBu", "PuBuGn", "PuRd", "Purples", + "RdPu", "Reds", "YlGn", "YlGnBu", "YlOrBr", "YlOrRd" + ) + if (!is.null(theme) && theme == "jama") { col.pal <- c("#00AFBB", "#E7B800", "#FC4E07") - col.pal <- rep(col.pal, ceiling(length(ystratalabs)/3)) + col.pal <- rep(col.pal, ceiling(length(ystratalabs) / 3)) } else if (all(linecols %in% brewer.palette)) { col.pal <- NULL } else { col.pal <- linecols - col.pal <- rep(col.pal, ceiling(length(ystratalabs)/length(linecols))) + col.pal <- rep(col.pal, ceiling(length(ystratalabs) / length(linecols))) } - + if (is.null(col.pal)) { p <- p + scale_colour_brewer(name = ystrataname, palette = linecols) } else { diff --git a/R/svyjskm.R b/R/svyjskm.R index 898717b..eee69dc 100644 --- a/R/svyjskm.R +++ b/R/svyjskm.R @@ -317,26 +317,28 @@ svyjskm <- function(sfit, scale_linetype_manual(name = ystrataname, values = linetype) } - brewer.palette <- c("BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", "RdYlBu", "RdYlGn", "Spectral", "Accent", "Dark2", "Paired", "Pastel1", "Pastel2", - "Set1", "Set2", "Set3", "Blues", "BuGn", "BuPu", "GnBu", "Greens", "Greys", "Oranges", "OrRd", "PuBu", "PuBuGn", "PuRd", "Purples", - "RdPu", "Reds", "YlGn", "YlGnBu", "YlOrBr", "YlOrRd") - + brewer.palette <- c( + "BrBG", "PiYG", "PRGn", "PuOr", "RdBu", "RdGy", "RdYlBu", "RdYlGn", "Spectral", "Accent", "Dark2", "Paired", "Pastel1", "Pastel2", + "Set1", "Set2", "Set3", "Blues", "BuGn", "BuPu", "GnBu", "Greens", "Greys", "Oranges", "OrRd", "PuBu", "PuBuGn", "PuRd", "Purples", + "RdPu", "Reds", "YlGn", "YlGnBu", "YlOrBr", "YlOrRd" + ) + if (!is.null(theme) && theme == "jama") { col.pal <- c("#00AFBB", "#E7B800", "#FC4E07") - col.pal <- rep(col.pal, ceiling(length(ystratalabs)/3)) + col.pal <- rep(col.pal, ceiling(length(ystratalabs) / 3)) } else if (all(linecols %in% brewer.palette)) { col.pal <- NULL } else { col.pal <- linecols - col.pal <- rep(col.pal, ceiling(length(ystratalabs)/length(linecols))) + col.pal <- rep(col.pal, ceiling(length(ystratalabs) / length(linecols))) } - + if (is.null(col.pal)) { p <- p + scale_colour_brewer(name = ystrataname, palette = linecols) } else { p <- p + scale_color_manual(name = ystrataname, values = col.pal) } - + # Add 95% CI to plot if (ci == TRUE) { if (all(linecols2 == "black")) {