Use adapted D3 palette as default
... instead of IDS department colours, which could be misleading.
Also add "poly20" palette and make "grey" palette usable from for ggplot2
Change-Id: Ic31cb5ecf881e232d3fc9209b63b19b8705a40b8
diff --git a/NAMESPACE b/NAMESPACE
index e97eb00..c55aa89 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -6,6 +6,8 @@
export(idsPalette)
export(idsPaletteD3)
export(idsPaletteGreyscale)
+export(idsPaletteIDS)
+export(idsPalettePoly20)
export(ids_pal)
export(scale_color_ids)
export(scale_colour_ids)
diff --git a/R/idsThemeR.R b/R/idsThemeR.R
index 6693c96..0465942 100644
--- a/R/idsThemeR.R
+++ b/R/idsThemeR.R
@@ -7,7 +7,7 @@
#' @export
#'
#' @examples
-idsPalette <- function() {
+idsPaletteIDS <- function() {
c(
'#F18700',
"#1E2662",
@@ -69,12 +69,35 @@
#' @export
#'
#' @examples
+idsPalettePoly20 <- function() {
+ c(
+ "#EF8700", "#1642FF", "#00D20D", "#FF00CB", "#162E35", "#00C8FC", "#FF004B", "#BBB96A", "#DFA2ED", "#881640", "#22D0AD", "#CF0DF7",
+ "#2E0D95", "#AFB9BD", "#FC4792", "#EBA392", "#1C7C00", "#939CFF", "#AB00A4", "#AF1C00"
+ )
+}
+
+#' Title
+#'
+#' @return
+#' @export
+#'
+#' @examples
idsPaletteGreyscale <- function() {
c(
"#000000", "#B2B0AD", "#737373", "#D8D7D6", "#B2B0AD", "#8C8984"
)
}
+#' Title
+#'
+#' @return
+#' @export
+#'
+#' @examples
+idsPalette <- function() {
+ idsPaletteD3()
+}
+
backgroundColorDark <- "#2a2a2a"
textColorDark <- "#E0E0E3"
lowContrastColorDark <- "#707073"
@@ -93,7 +116,7 @@
#' IDS color palette
#'
-#' @param palette \code{c("D3", "default")} - use default or (adapted) d3 palette
+#' @param palette \code{c("d3", "grey", "ids", "poly20")} - default: (adapted) d3 palette
#'
#' @importFrom scales manual_pal
#' @export
@@ -103,7 +126,13 @@
#' \url{https://github.com/d3/d3}
#'
ids_pal <- function(palette="default") {
- values <- if(palette == "d3" || palette == "D3") idsPaletteD3() else idsPalette()
+ values <- switch(tolower(palette),
+ ids = idsPalette(),
+ gray = idsPaletteGreyscale(),
+ grey = idsPaletteGreyscale(),
+ poly20 = idsPalettePoly20(),
+ idsPaletteD3()
+ )
f <- scales::manual_pal(values)
attr(f, "max_n") <- length(values)
f
diff --git a/Readme.md b/Readme.md
index 2a9eee5..28b044c 100644
--- a/Readme.md
+++ b/Readme.md
@@ -11,18 +11,18 @@
```
## Examples
-### [highcharter](https://cran.r-project.org/package=highcharter) – light
+### [highcharter](https://cran.r-project.org/package=highcharter) – light with IDS departments palette
```R
library(tidyverse)
library(highcharter)
library(idsThemeR)
highcharts_demo() %>%
- hc_add_theme(hc_theme_ids_light())
+ hc_add_theme(hc_theme_ids_light(palette = "ids"))
```
![](./man/figures/Readme-Example-1.png)<!-- -->
-### ggplot2 – dark with alternative colour palette
+### ggplot2 – dark with default colour palette
```R
library(ggplot2)
@@ -46,11 +46,11 @@
geom_point(size = 1.1) +
ggtitle("Monthly Average Temperature") +
theme_ids(style="dark") +
- scale_colour_ids(palette="D3")
+ scale_colour_ids()
```
![](./man/figures/Readme-Example-2.png)<!-- -->
-### ggplot2 – light
+### ggplot2 – light with IDS departments palette
```R
dtemp <- data.frame(Months = factor(rep(substr(month.name, 1, 3), 4),
@@ -71,7 +71,7 @@
geom_point(size = 1.1) +
ggtitle("Monthly Average Temperature", subtitle="Source: WorldClimate.com") +
theme_ids() +
- scale_colour_ids()
+ scale_colour_ids(palette = "ids")
```
![](./man/figures/Readme-Example-3.png)<!-- -->
diff --git a/man/ids_pal.Rd b/man/ids_pal.Rd
index 96c9313..0bbe8fb 100644
--- a/man/ids_pal.Rd
+++ b/man/ids_pal.Rd
@@ -7,7 +7,7 @@
ids_pal(palette = "default")
}
\arguments{
-\item{palette}{\code{c("D3", "default")} - use default or (adapted) d3 palette}
+\item{palette}{\code{c("d3", "grey", "ids", "poly20")} - default: (adapted) d3 palette}
}
\description{
IDS color palette