From d9ef30f91bf2361ba4c42bab854dfc411f3897d6 Mon Sep 17 00:00:00 2001 From: Carl Goodwin Date: Sat, 29 Jun 2024 10:58:17 +0100 Subject: [PATCH] Respect color or colour in display_palette() --- R/geom_casting.R | 14 +++++++------- man/display_palette.Rd | 12 +++++------- ...{file28112b87d9ed.png => filee7ce2addf9c9.png} | Bin ...{file2811311eea5c.png => filee7ce53a92ea4.png} | Bin ...{file2811735201e4.png => filee7ce650ea449.png} | Bin 5 files changed, 12 insertions(+), 14 deletions(-) rename tests/testthat/_snaps/geom_casting/{file28112b87d9ed.png => filee7ce2addf9c9.png} (100%) rename tests/testthat/_snaps/geom_casting/{file2811311eea5c.png => filee7ce53a92ea4.png} (100%) rename tests/testthat/_snaps/geom_casting/{file2811735201e4.png => filee7ce650ea449.png} (100%) diff --git a/R/geom_casting.R b/R/geom_casting.R index 1c9c9b8..4aff8ca 100644 --- a/R/geom_casting.R +++ b/R/geom_casting.R @@ -177,11 +177,8 @@ GeomCasting <- ggproto("GeomCasting", Geom, #' #' @param pal_name A character string for the name of the palette. #' -#' @param colour The colour of the shape outline. Defaults to mid-grey to better -#' support a website's light and dark mode. -#' -#' @param color The color of the shape outline. Defaults to mid-grey to better -#' support a website's light and dark mode. +#' @param colour,color The colour of the shape outline. Defaults to mid-grey to +#' better support a website's light and dark mode. #' #' @param shape A character string for the name of the shape, e.g. "jar". #' @@ -195,7 +192,8 @@ GeomCasting <- ggproto("GeomCasting", Geom, #' display_palette( #' c("#9986A5", "#79402E", "#CCBA72", "#0F0D0E", "#D9D0D3", "#8D8680"), #' "Vector of Hex Codes", -#' shape = "tube" +#' shape = "tube", +#' colour = "black" #' ) #' display_palette( #' c( @@ -205,8 +203,10 @@ GeomCasting <- ggproto("GeomCasting", Geom, #' "Multiple Rows" #' ) display_palette <- \(fill, pal_name, colour = "grey50", - color = colour, shape = "jar"){ + color = colour, shape = c("jar", "tube")){ + shape = shape[1] + colour = color n <- length(fill) x <- (1:n - 1) %% 6 + 1 y <- (1:n - 1) %/% 6 + 1 diff --git a/man/display_palette.Rd b/man/display_palette.Rd index 7d0fbd0..02f9a63 100644 --- a/man/display_palette.Rd +++ b/man/display_palette.Rd @@ -9,7 +9,7 @@ display_palette( pal_name, colour = "grey50", color = colour, - shape = "jar" + shape = c("jar", "tube") ) } \arguments{ @@ -17,11 +17,8 @@ display_palette( \item{pal_name}{A character string for the name of the palette.} -\item{colour}{The colour of the shape outline. Defaults to mid-grey to better -support a website's light and dark mode.} - -\item{color}{The color of the shape outline. Defaults to mid-grey to better -support a website's light and dark mode.} +\item{colour, color}{The colour of the shape outline. Defaults to mid-grey to +better support a website's light and dark mode.} \item{shape}{A character string for the name of the shape, e.g. "jar".} } @@ -42,7 +39,8 @@ display_palette( display_palette( c("#9986A5", "#79402E", "#CCBA72", "#0F0D0E", "#D9D0D3", "#8D8680"), "Vector of Hex Codes", - shape = "tube" + shape = "tube", + colour = "black" ) display_palette( c( diff --git a/tests/testthat/_snaps/geom_casting/file28112b87d9ed.png b/tests/testthat/_snaps/geom_casting/filee7ce2addf9c9.png similarity index 100% rename from tests/testthat/_snaps/geom_casting/file28112b87d9ed.png rename to tests/testthat/_snaps/geom_casting/filee7ce2addf9c9.png diff --git a/tests/testthat/_snaps/geom_casting/file2811311eea5c.png b/tests/testthat/_snaps/geom_casting/filee7ce53a92ea4.png similarity index 100% rename from tests/testthat/_snaps/geom_casting/file2811311eea5c.png rename to tests/testthat/_snaps/geom_casting/filee7ce53a92ea4.png diff --git a/tests/testthat/_snaps/geom_casting/file2811735201e4.png b/tests/testthat/_snaps/geom_casting/filee7ce650ea449.png similarity index 100% rename from tests/testthat/_snaps/geom_casting/file2811735201e4.png rename to tests/testthat/_snaps/geom_casting/filee7ce650ea449.png