From 0df7aee06dc47d748d01cbde2adcc69fa9ceebd4 Mon Sep 17 00:00:00 2001 From: Alboukadel Kassambara Date: Tue, 21 Apr 2020 08:07:37 +0200 Subject: [PATCH] New argument vjust added #210 --- NEWS.md | 1 + R/stat_compare_means.R | 7 ++++--- man/stat_compare_means.Rd | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/NEWS.md b/NEWS.md index 41423320..948913aa 100644 --- a/NEWS.md +++ b/NEWS.md @@ -13,6 +13,7 @@ ## Minor changes - New arguments: + - `vjsut` in `stat_compare_means()` to move the text up or down relative to the bracket. - `type` in `geom_bracket()` to specify label type. Can be "text" or "expression" (for parsing plotmath expression); [#253](https://github.com/kassambara/ggpubr/issues/253). - `labeller` to the function `facet()` - `position` in `get_legend()` to specify legend position diff --git a/R/stat_compare_means.R b/R/stat_compare_means.R index 3c5c4657..a66f80a7 100644 --- a/R/stat_compare_means.R +++ b/R/stat_compare_means.R @@ -28,6 +28,7 @@ NULL #' allowed values include: i) one of c('right', 'left', 'center', 'centre', #' 'middle') for x-axis; ii) and one of c( 'bottom', 'top', 'center', 'centre', #' 'middle') for y-axis.} +#'@param vjust move the text up or down relative to the bracket. #'@param tip.length numeric vector with the fraction of total height that the #' bar goes down to indicate the precise column. Default is 0.03. Can be of #' same length as the number of comparisons to adjust specifically the tip @@ -100,7 +101,7 @@ stat_compare_means <- function(mapping = NULL, data = NULL, method = NULL, paired = FALSE, method.args = list(), ref.group = NULL, comparisons = NULL, hide.ns = FALSE, label.sep = ", ", label = NULL, label.x.npc = "left", label.y.npc = "top", - label.x = NULL, label.y = NULL, tip.length = 0.03, + label.x = NULL, label.y = NULL, vjust = 0, tip.length = 0.03, bracket.size = 0.3, step.increase = 0, symnum.args = list(), geom = "text", position = "identity", na.rm = FALSE, show.legend = NA, @@ -144,7 +145,7 @@ stat_compare_means <- function(mapping = NULL, data = NULL, test = method, test.args = method.args, step_increase = step.increase, size = bracket.size, textsize = size, color = color, map_signif_level = map_signif_level, tip_length = tip.length, - data = data) + data = data, vjust = vjust) } else{ @@ -157,7 +158,7 @@ stat_compare_means <- function(mapping = NULL, data = NULL, method = method, method.args = method.args, paired = paired, ref.group = ref.group, symnum.args = symnum.args, - hide.ns = hide.ns, na.rm = na.rm, ...) + hide.ns = hide.ns, na.rm = na.rm, vjust = vjust,...) ) } diff --git a/man/stat_compare_means.Rd b/man/stat_compare_means.Rd index a20ecb75..6320ea22 100644 --- a/man/stat_compare_means.Rd +++ b/man/stat_compare_means.Rd @@ -19,6 +19,7 @@ stat_compare_means( label.y.npc = "top", label.x = NULL, label.y = NULL, + vjust = 0, tip.length = 0.03, bracket.size = 0.3, step.increase = 0, @@ -95,6 +96,8 @@ allowed values include: i) one of c('right', 'left', 'center', 'centre', \item{label.x, label.y}{\code{numeric} Coordinates (in data units) to be used for absolute positioning of the label. If too short they will be recycled.} +\item{vjust}{move the text up or down relative to the bracket.} + \item{tip.length}{numeric vector with the fraction of total height that the bar goes down to indicate the precise column. Default is 0.03. Can be of same length as the number of comparisons to adjust specifically the tip