From cd9bcd9c60d9f5b35b3d2bac4bc22aa22d0b5e5a Mon Sep 17 00:00:00 2001 From: Alboukadel Kassambara Date: Sun, 10 May 2020 12:36:57 +0200 Subject: [PATCH] New argument stroke added #236 --- NEWS.md | 1 + R/geom_exec.R | 2 ++ R/ggline.R | 10 ++++++---- man/ggline.Rd | 3 +++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/NEWS.md b/NEWS.md index 866bbde0..4d4dd2ab 100644 --- a/NEWS.md +++ b/NEWS.md @@ -12,6 +12,7 @@ ## Minor changes +- New argument `stroke` supported in `ggscatter()` and in `ggline()`. Used only for shapes 21-24 to control the thickness of points border ([@bioguy2018, #258](https://github.com/kassambara/ggpubr/issues/236)). - the `stat_cor()` function code has been simplified. New arguments `p.accuracy` and `r.accuracy` added; a real value specifying the number of decimal places of precision for the p-value and the correlation coefficient, respectively. Default is NULL. Use (e.g.) 0.01 to show 2 decimal places of precision ([@garthtarr, #186](https://github.com/kassambara/ggpubr/issues/186), [@raedevan6, #114](https://github.com/kassambara/ggpubr/issues/114), [#270](https://github.com/kassambara/ggpubr/issues/270)). diff --git a/R/geom_exec.R b/R/geom_exec.R index d75d2b7d..604ea97b 100644 --- a/R/geom_exec.R +++ b/R/geom_exec.R @@ -29,6 +29,8 @@ geom_exec <- function (geomfunc = NULL, data = NULL, "x", "y", "color", "colour", "linetype", "fill", "size", "shape", "width", "alpha", "na.rm", "lwd", "pch", "cex", "position", "stat", "geom", "show.legend", "inherit.aes", "fun.args", "fontface", + # point + "stroke", # boxplot "outlier.colour", "outlier.shape", "outlier.size", "outlier.stroke", "notch", "notchwidth", "varwidth", diff --git a/R/ggline.R b/R/ggline.R index e4c53e89..039bee32 100644 --- a/R/ggline.R +++ b/R/ggline.R @@ -14,6 +14,7 @@ NULL #' @param plot_type plot type. Allowed values are one of "b" for both line and point; #' "l" for line only; and "p" for point only. Default is "b". #' @param shape point shapes. +#' @param stroke point stroke. Used only for shapes 21-24 to control the thickness of points border. #' @param show.line.label logical value. If TRUE, shows line labels. #' @param point.size point size. #' @param point.color point color. @@ -123,7 +124,8 @@ ggline<- function(data, x, y, group = 1, color = "black", palette = NULL, linetype = "solid", plot_type = c("b", "l", "p"), - size = 0.5, shape = 19, point.size = size, point.color = color, + size = 0.5, shape = 19, stroke = NULL, + point.size = size, point.color = color, title = NULL, xlab = NULL, ylab = NULL, facet.by = NULL, panel.labs = NULL, short.panel.labs = TRUE, select = NULL, remove = NULL, order = NULL, @@ -145,7 +147,7 @@ ggline<- function(data, x, y, group = 1, combine = combine, merge = merge, color = color, palette = palette, linetype = linetype, plot_type = plot_type, - size = size, shape = shape, + size = size, shape = shape, stroke = stroke, point.size = point.size, point.color = point.color, title = title, xlab = xlab, ylab = ylab, facet.by = facet.by, panel.labs = panel.labs, short.panel.labs = short.panel.labs, @@ -183,7 +185,7 @@ ggline_core <- function(data, x, y, group = 1, color = "black", fill = "white", palette = NULL, linetype = "solid", plot_type = c("b", "l", "p"), - size = 0.5, shape = 19, + size = 0.5, shape = 19, stroke = NULL, point.size = size, point.color = color, title = NULL, xlab = NULL, ylab = NULL, select = NULL, order = NULL, @@ -279,7 +281,7 @@ ggline_core <- function(data, x, y, group = 1, p <- p + geom_exec(geom_point, data = data_sum, color = point.color, shape = shape, - size = 1.2+point.size) + size = 1.2+point.size, stroke = stroke) # Adjust shape when ngroups > 6, to avoid ggplot warnings p <-.scale_point_shape(p, data_sum, shape) } diff --git a/man/ggline.Rd b/man/ggline.Rd index ea95966a..e0582346 100644 --- a/man/ggline.Rd +++ b/man/ggline.Rd @@ -18,6 +18,7 @@ ggline( plot_type = c("b", "l", "p"), size = 0.5, shape = 19, + stroke = NULL, point.size = size, point.color = color, title = NULL, @@ -81,6 +82,8 @@ outlines.} \item{shape}{point shapes.} +\item{stroke}{point stroke. Used only for shapes 21-24 to control the thickness of points border.} + \item{point.size}{point size.} \item{point.color}{point color.}