diff --git a/R/geom-statebins.r b/R/geom-statebins.r index 7d79a9d..4fe94c9 100644 --- a/R/geom-statebins.r +++ b/R/geom-statebins.r @@ -30,7 +30,7 @@ #' @param border_col border color of the state squares, default "`white`" #' @param border_size thickness of the square state borders #' @param lbl_size font size (relative) of the label text -#' @param dark_lbl,light_lbl colrs to be uses when the label should be dark or light. +#' @param dark_lbl,light_lbl,na_lbl colors to be uses when the label should be dark, light, or NA. #' The function automagically computes when this should be. #' @param radius the corner radius #' @param na.rm If `FALSE`, the default, missing values are removed with @@ -72,7 +72,7 @@ geom_statebins <- function( mapping = NULL, data = NULL, border_col = "white", border_size = 2, - lbl_size = 3, dark_lbl = "black", light_lbl = "white", + lbl_size = 3, dark_lbl = "black", light_lbl = "white", na_lbl = "white", radius = grid::unit(6, "pt"), ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) { @@ -147,6 +147,7 @@ GeomStatebins <- ggplot2::ggproto("GeomStatebins", ggplot2::Geom, draw_panel = function(self, data, panel_params, coord, border_col = "white", border_size = 2, lbl_size = 3, dark_lbl = "black", light_lbl = "white", + na_lbl = "white", radius = grid::unit(6, "pt")) { tile_data <- data @@ -158,7 +159,7 @@ GeomStatebins <- ggplot2::ggproto("GeomStatebins", ggplot2::Geom, text_data$label <- data$abbrev text_data$fill <- NA text_data$size <- lbl_size - text_data$colour <- .sb_invert(data$fill, dark_lbl, light_lbl) + text_data$colour <- .sb_invert(data$fill, dark_lbl, light_lbl, na_lbl) coord <- coord_equal() diff --git a/man/geom_statebins.Rd b/man/geom_statebins.Rd index 7ea0cec..73172ce 100644 --- a/man/geom_statebins.Rd +++ b/man/geom_statebins.Rd @@ -9,8 +9,8 @@ \usage{ geom_statebins(mapping = NULL, data = NULL, border_col = "white", border_size = 2, lbl_size = 3, dark_lbl = "black", - light_lbl = "white", radius = grid::unit(6, "pt"), ..., na.rm = FALSE, - show.legend = NA, inherit.aes = TRUE) + light_lbl = "white", na_lbl = "white", radius = grid::unit(6, "pt"), + ..., na.rm = FALSE, show.legend = NA, inherit.aes = TRUE) GeomStatebins } @@ -40,7 +40,7 @@ will be used as the layer data.} \item{lbl_size}{font size (relative) of the label text} -\item{dark_lbl, light_lbl}{colrs to be uses when the label should be dark or light. +\item{dark_lbl, light_lbl, na_lbl}{colors to be uses when the label should be dark, light, or NA. The function automagically computes when this should be.} \item{radius}{the corner radius}