diff --git a/NEWS.md b/NEWS.md index b7033b51..507c989e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -20,6 +20,7 @@ ## Bug fixes +- Now, `ggscatter()` can remove the letter 'a' from the legend, when the argument `show.legend.text = FALSE` specified [@atsyplenkov, #106](https://github.com/kassambara/ggpubr/issues/106). - Now, adding a `size` option to ggscatter `add.params` is supported [@retrogenomics, #94](https://github.com/kassambara/ggpubr/issues/53). # ggpubr 0.1.7 diff --git a/R/ggtext.R b/R/ggtext.R index da0b765b..3e51c3aa 100644 --- a/R/ggtext.R +++ b/R/ggtext.R @@ -12,6 +12,9 @@ NULL #' @param face text font style. Allowed values are one of c("plain", "bold", #' "italic", "bold.italic"). #' @param family character vector specifying font family. +#' @param show.legend logical. Should text be included in the legends? NA, +#' the default, includes if any aesthetics are mapped. FALSE never includes, +#' and TRUE always includes. #' @param label.select can be of two formats: \itemize{ \item a character vector #' specifying some labels to show. \item a list containing one or the #' combination of the following components: \itemize{ \item \code{top.up} and @@ -60,7 +63,7 @@ NULL #' @export ggtext <- function(data, x = NULL, y = NULL, label = NULL, color = "black", palette = NULL, - size = 11, face = "plain", family = "", + size = 11, face = "plain", family = "", show.legend = NA, label.select = NULL, repel = FALSE, label.rectangle = FALSE, grouping.vars = NULL, position = "identity", @@ -128,7 +131,7 @@ ggtext <- function(data, x = NULL, y = NULL, label = NULL, if(label.rectangle) ggfunc <- ggrepel::geom_label_repel p <- p + geom_exec(ggfunc, data = lab_data, x = x, y = y, label = label, fontface = face, - family = family, + family = family, show.legend = show.legend, size = size/3, color = color, alpha = alpha, box.padding = unit(0.35, "lines"), @@ -146,7 +149,7 @@ ggtext <- function(data, x = NULL, y = NULL, label = NULL, vjust <- ifelse(is.null(.dots$vjust), vjust, .dots$vjust) if(!is.null(.dots$hjust)) hjust <- .dots$hjust p <- p + geom_exec(ggfunc, data = lab_data, x = x, y = y, color = color, - label = label, fontface = face, family = family, + label = label, fontface = face, family = family, show.legend = show.legend, size = size/3, color = color, vjust = vjust, hjust = hjust, alpha = alpha, position = position) diff --git a/R/utilities.R b/R/utilities.R index 834ac566..b385b005 100644 --- a/R/utilities.R +++ b/R/utilities.R @@ -809,6 +809,7 @@ p label.select = NULL, repel = FALSE, label.rectangle = FALSE, ggtheme = theme_pubr(), fun_name = "", group = 1, # used only by ggline + show.legend.text = NA, ...) { @@ -942,7 +943,8 @@ p .add_item(data = data, x = opts$x, y = opts$y, label = label, label.select = label.select, repel = repel, label.rectangle = label.rectangle, ggtheme = NULL, - grouping.vars = grouping.vars, facet.by = facet.by, position = geom.text.position) + grouping.vars = grouping.vars, facet.by = facet.by, position = geom.text.position, + show.legend = show.legend.text) p <- purrr::map(p, function(p, label.opts){ . <- NULL diff --git a/man/ggtext.Rd b/man/ggtext.Rd index 8fac707c..5fae6bfa 100644 --- a/man/ggtext.Rd +++ b/man/ggtext.Rd @@ -6,9 +6,9 @@ \usage{ ggtext(data, x = NULL, y = NULL, label = NULL, color = "black", palette = NULL, size = 11, face = "plain", family = "", - label.select = NULL, repel = FALSE, label.rectangle = FALSE, - grouping.vars = NULL, position = "identity", ggp = NULL, - ggtheme = theme_pubr(), ...) + show.legend = NA, label.select = NULL, repel = FALSE, + label.rectangle = FALSE, grouping.vars = NULL, position = "identity", + ggp = NULL, ggtheme = theme_pubr(), ...) } \arguments{ \item{data}{a data frame} @@ -33,6 +33,10 @@ scientific journal palettes from ggsci R package, e.g.: "npg", "aaas", \item{family}{character vector specifying font family.} +\item{show.legend}{logical. Should text be included in the legends? NA, +the default, includes if any aesthetics are mapped. FALSE never includes, +and TRUE always includes.} + \item{label.select}{can be of two formats: \itemize{ \item a character vector specifying some labels to show. \item a list containing one or the combination of the following components: \itemize{ \item \code{top.up} and