From 3e58903e5a4604c5850db625d2bf4370468e87e5 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 29 Jun 2021 09:42:02 -0400 Subject: [PATCH 1/2] Use ggtext::geom_richtext --- R/geom_node_text.R | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/R/geom_node_text.R b/R/geom_node_text.R index c7075177..3081a4e1 100644 --- a/R/geom_node_text.R +++ b/R/geom_node_text.R @@ -90,7 +90,7 @@ geom_node_label <- function(mapping = NULL, data = NULL, position = 'identity', label.padding = unit(0.25, 'lines'), label.r = unit(0.15, 'lines'), label.size = 0.25, show.legend = NA, - repel = FALSE, ...) { + repel = FALSE, richtext = TRUE, ...) { if (!missing(nudge_x) || !missing(nudge_y)) { if (!missing(position)) { stop('Specify either `position` or `nudge_x`/`nudge_y`', @@ -105,6 +105,8 @@ geom_node_label <- function(mapping = NULL, data = NULL, position = 'identity', ) if (repel) { geom <- GeomLabelRepel + } else if (richtext) { + geom <- ggtext::GeomRichText } else { geom <- GeomLabel } From 8887190c3e91210496b9e912ea1e84fe5465ff68 Mon Sep 17 00:00:00 2001 From: Kelly Sovacool Date: Tue, 29 Jun 2021 09:50:09 -0400 Subject: [PATCH 2/2] Update docs --- R/geom_node_text.R | 4 +++- man/geom_node_text.Rd | 4 ++++ man/scale_edge_colour.Rd | 23 +++++++++++++++++------ man/scale_edge_fill.Rd | 23 +++++++++++++++++------ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/R/geom_node_text.R b/R/geom_node_text.R index 3081a4e1..2b97c1e6 100644 --- a/R/geom_node_text.R +++ b/R/geom_node_text.R @@ -81,7 +81,9 @@ geom_node_text <- function(mapping = NULL, data = NULL, position = 'identity', #' @rdname geom_node_text #' #' @inheritParams ggplot2::geom_label -#' +#' @param richtext whether to parse markdown/CSS in the text label like +#' `ggtext::geom_richtext()`. +#' #' @importFrom ggrepel GeomLabelRepel #' @export #' diff --git a/man/geom_node_text.Rd b/man/geom_node_text.Rd index 407590e8..fa9ff31a 100644 --- a/man/geom_node_text.Rd +++ b/man/geom_node_text.Rd @@ -30,6 +30,7 @@ geom_node_label( label.size = 0.25, show.legend = NA, repel = FALSE, + richtext = TRUE, ... ) } @@ -88,6 +89,9 @@ to the paired geom/stat.} \item{label.r}{Radius of rounded corners. Defaults to 0.15 lines.} \item{label.size}{Size of label border, in mm.} + +\item{richtext}{whether to parse markdown/CSS in the text label like +\code{ggtext::geom_richtext()}.} } \description{ These geoms are equivalent in functionality to \code{\link[ggplot2:geom_text]{ggplot2::geom_text()}} and diff --git a/man/scale_edge_colour.Rd b/man/scale_edge_colour.Rd index fe55bfd3..6319b64c 100644 --- a/man/scale_edge_colour.Rd +++ b/man/scale_edge_colour.Rd @@ -305,15 +305,26 @@ Defaults to 0.} \item{end}{grey value at high end of palette} -\item{alpha}{pass through parameter to \code{viridis}} +\item{alpha}{The alpha transparency, a number in [0,1], see argument alpha in +\code{\link[grDevices]{hsv}}.} -\item{begin}{The (corrected) hue in [0,1] at which the viridis colormap begins.} +\item{begin}{The (corrected) hue in [0,1] at which the color map begins.} -\item{discrete}{generate a discrete palette? (default: \code{FALSE} - generate continuous palette)} +\item{discrete}{Generate a discrete palette? (default: \code{FALSE} - +generate continuous palette).} -\item{option}{A character string indicating the colormap option to use. Four -options are available: "magma" (or "A"), "inferno" (or "B"), "plasma" (or "C"), -"viridis" (or "D", the default option) and "cividis" (or "E").} +\item{option}{A character string indicating the color map option to use. +Eight options are available: +\itemize{ + \item "magma" (or "A") + \item "inferno" (or "B") + \item "plasma" (or "C") + \item "viridis" (or "D") + \item "cividis" (or "E") + \item "rocket" (or "F") + \item "mako" (or "G") + \item "turbo" (or "H") +}} } \value{ A ggproto object inheriting from \code{Scale} diff --git a/man/scale_edge_fill.Rd b/man/scale_edge_fill.Rd index 971ba50b..faabe84c 100644 --- a/man/scale_edge_fill.Rd +++ b/man/scale_edge_fill.Rd @@ -205,15 +205,26 @@ Defaults to 0.} \item{end}{grey value at high end of palette} -\item{alpha}{pass through parameter to \code{viridis}} +\item{alpha}{The alpha transparency, a number in [0,1], see argument alpha in +\code{\link[grDevices]{hsv}}.} -\item{begin}{The (corrected) hue in [0,1] at which the viridis colormap begins.} +\item{begin}{The (corrected) hue in [0,1] at which the color map begins.} -\item{discrete}{generate a discrete palette? (default: \code{FALSE} - generate continuous palette)} +\item{discrete}{Generate a discrete palette? (default: \code{FALSE} - +generate continuous palette).} -\item{option}{A character string indicating the colormap option to use. Four -options are available: "magma" (or "A"), "inferno" (or "B"), "plasma" (or "C"), -"viridis" (or "D", the default option) and "cividis" (or "E").} +\item{option}{A character string indicating the color map option to use. +Eight options are available: +\itemize{ + \item "magma" (or "A") + \item "inferno" (or "B") + \item "plasma" (or "C") + \item "viridis" (or "D") + \item "cividis" (or "E") + \item "rocket" (or "F") + \item "mako" (or "G") + \item "turbo" (or "H") +}} } \value{ A ggproto object inheriting from \code{Scale}