Use proper IDS CD default palette and bump to v0.3.0
Thanks @Sascha!
Change-Id: If0ba7262141dbf0b257dbc3288a615bca4c70455
diff --git a/Changelog.md b/Changelog.md
index 8e74e6f..0306a2a 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -1,5 +1,9 @@
# Changelog
+## 0.3.0
+* use proper IDS CD palette as default palette (thanks @Sascha)
+* add palette displays to Readme.md
+
## 0.2.0
* themes and palettes for ggplot2 added: `theme_ids()`, `theme_ids(style="dark")`, `scale_colour_ids()`, `scale_fill_ids()`
* centralised initialisation for colours and palettes
diff --git a/DESCRIPTION b/DESCRIPTION
index 679e432..94b1929 100644
--- a/DESCRIPTION
+++ b/DESCRIPTION
@@ -1,7 +1,7 @@
Package: idsThemeR
Type: Package
Title: Plot themes for the Leibniz Institute for the German Language (IDS)
-Version: 0.2.0
+Version: 0.3.0
Authors@R:
c(person(given = "Marc",
family = "Kupietz",
diff --git a/R/ggplot-theme.R b/R/ggplot-theme.R
index fb3176b..0f6aabe 100644
--- a/R/ggplot-theme.R
+++ b/R/ggplot-theme.R
@@ -90,7 +90,7 @@
#' @rdname scale_ids
#' @export
scale_colour_ids <- function(palette = "default", ...) {
- discrete_scale("colour", "ids", ids_pal(), ...)
+ discrete_scale("colour", "ids", ids_pal(palette=palette, ...))
}
#' @rdname scale_ids
@@ -104,5 +104,5 @@
#' @importFrom ggplot2 discrete_scale
#' @export
scale_fill_ids <- function(palette = "default", ...) {
- discrete_scale("fill", "ids", ids_pal(), ...)
+ discrete_scale("fill", "ids", ids_pal(palette=palette, ...))
}
diff --git a/R/idsThemeR.R b/R/idsThemeR.R
index d62f03c..bfab33a 100644
--- a/R/idsThemeR.R
+++ b/R/idsThemeR.R
@@ -1,6 +1,29 @@
idsBaseFontFamily <- 'Fira Sans Condensed'
idsPalette <- c(
+ '#F18700',
+ "#1E2662",
+ "#6A7702",
+ "#C10A25",
+ "#009EE3",
+ "#FAF3DE",
+ "#A7C2D2",
+ "#E2E8A4",
+ "#CFBCBD",
+ "#BCE3FA",
+ "#5C401C",
+ "#000000",
+ "#354C32",
+ "#5C131C",
+ "#273582",
+ "#FFE3BF",
+ "#8994E1",
+ "#A3B29E",
+ "#DF9599",
+ "#79B8DB"
+)
+
+idsPaletteD3 <- c(
'#EB7C31',
"#1F77B4",
"#2CA02C",
@@ -43,7 +66,9 @@
candlestickColor <- "black"
errorbarColor <- "black"
-#' IDS color palette based on the d3 color palette
+#' IDS color palette
+#'
+#' @param palette \code{c("D3", "default")} - use default or (adapted) d3 palette
#'
#' @importFrom scales manual_pal
#' @export
@@ -52,8 +77,8 @@
#'
#' \url{https://github.com/d3/d3}
#'
-ids_pal <- function() {
- values <- idsPalette
+ids_pal <- function(palette="default") {
+ values <- if(palette == "d3" || palette == "D3") idsPaletteD3 else idsPalette
f <- scales::manual_pal(values)
attr(f, "max_n") <- length(values)
f
diff --git a/Readme.md b/Readme.md
index 650b133..2a9eee5 100644
--- a/Readme.md
+++ b/Readme.md
@@ -22,7 +22,7 @@
```
![](./man/figures/Readme-Example-1.png)<!-- -->
-### ggplot2 – dark
+### ggplot2 – dark with alternative colour palette
```R
library(ggplot2)
@@ -46,7 +46,7 @@
geom_point(size = 1.1) +
ggtitle("Monthly Average Temperature") +
theme_ids(style="dark") +
- scale_colour_ids()
+ scale_colour_ids(palette="D3")
```
![](./man/figures/Readme-Example-2.png)<!-- -->
@@ -75,6 +75,23 @@
```
![](./man/figures/Readme-Example-3.png)<!-- -->
+### Default Palette
+```R
+library(scales)
+show_col(ids_pal()(20))
+```
+![](./man/figures/palette1.png)<!-- -->
+
+### Adapted D3 based Palette
+This palette should be used if the original palette colours can be misinterpreted
+as department colours.
+
+```R
+library(scales)
+show_col(ids_pal(palette="D3")(20))
+```
+![](./man/figures/paletteD3.png)<!-- -->
+
## Demos
More elaborate R scripts demonstrating the use of the package can be found in the [demo](demo) folder.
diff --git a/man/figures/Readme-Example-1.png b/man/figures/Readme-Example-1.png
index 213020f..4a0fbc5 100644
--- a/man/figures/Readme-Example-1.png
+++ b/man/figures/Readme-Example-1.png
Binary files differ
diff --git a/man/figures/Readme-Example-3.png b/man/figures/Readme-Example-3.png
index e97b0d8..13f81a1 100644
--- a/man/figures/Readme-Example-3.png
+++ b/man/figures/Readme-Example-3.png
Binary files differ
diff --git a/man/figures/palette1.png b/man/figures/palette1.png
new file mode 100644
index 0000000..4b2a577
--- /dev/null
+++ b/man/figures/palette1.png
Binary files differ
diff --git a/man/figures/paletteD3.png b/man/figures/paletteD3.png
new file mode 100644
index 0000000..5e273ce
--- /dev/null
+++ b/man/figures/paletteD3.png
Binary files differ
diff --git a/man/ids_pal.Rd b/man/ids_pal.Rd
index 15e0c3e..96c9313 100644
--- a/man/ids_pal.Rd
+++ b/man/ids_pal.Rd
@@ -2,12 +2,15 @@
% Please edit documentation in R/idsThemeR.R
\name{ids_pal}
\alias{ids_pal}
-\title{IDS color palette based on the d3 color palette}
+\title{IDS color palette}
\usage{
-ids_pal()
+ids_pal(palette = "default")
+}
+\arguments{
+\item{palette}{\code{c("D3", "default")} - use default or (adapted) d3 palette}
}
\description{
-IDS color palette based on the d3 color palette
+IDS color palette
}
\references{
\url{https://github.com/d3/d3}