Browse Source

Also the geom

master
Mathew Kiang 6 years ago
parent
commit
c85cdc7a83
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 7
      R/geom-statebins.r
  2. 6
      man/geom_statebins.Rd

7
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()

6
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}

Loading…
Cancel
Save