diff --git a/NAMESPACE b/NAMESPACE
index 43e14b66e..e4a91969e 100644
--- a/NAMESPACE
+++ b/NAMESPACE
@@ -37,7 +37,7 @@ export(gg_step)
export(gg_text)
export(gg_tile)
export(gg_violin)
-export(jumble)
+export(guardian)
export(light_mode)
export(str_keep_seq)
importFrom(magrittr,"%>%")
diff --git a/NEWS.md b/NEWS.md
index e2ce4e838..9b3499ede 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -1,6 +1,6 @@
# ggblanket 5.1.0900
-* Updated colours: `"steelblue"` where no col aesthetic, `jumble` where discrete and less than 5 colours, scales:hue_pal otherwise, `viridis::mako` reversed for continuous, and `"grey"` for NA.
+* Updated colours: `"steelblue"` where no col aesthetic, `guardian` where discrete and less than 5 colours, scales:hue_pal otherwise, `viridis::mako` reversed for continuous, and `"grey"` for NA.
* Breaking: removed all `pal_*` functions.
* Removed some unnecessary messages.
* Fixed bug where `col_breaks` was not working for a numeric `col`.
diff --git a/R/gg_area.R b/R/gg_area.R
index a5823ca6d..f3617f2ec 100644
--- a/R/gg_area.R
+++ b/R/gg_area.R
@@ -1222,7 +1222,7 @@ gg_area <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1230,8 +1230,8 @@ gg_area <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_bar.R b/R/gg_bar.R
index 2a5ffb631..2f6007010 100644
--- a/R/gg_bar.R
+++ b/R/gg_bar.R
@@ -1227,7 +1227,7 @@ gg_bar <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1235,8 +1235,8 @@ gg_bar <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_bin_2d.R b/R/gg_bin_2d.R
index be9fceebe..676450878 100644
--- a/R/gg_bin_2d.R
+++ b/R/gg_bin_2d.R
@@ -1248,7 +1248,7 @@ gg_bin_2d <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1256,8 +1256,8 @@ gg_bin_2d <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_blank.R b/R/gg_blank.R
index 0c40d919a..5695435ee 100644
--- a/R/gg_blank.R
+++ b/R/gg_blank.R
@@ -1586,7 +1586,7 @@ gg_blank <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1594,8 +1594,8 @@ gg_blank <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_boxplot.R b/R/gg_boxplot.R
index 6cfcc38ac..3bbbd008b 100644
--- a/R/gg_boxplot.R
+++ b/R/gg_boxplot.R
@@ -1227,7 +1227,7 @@ gg_boxplot <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1235,8 +1235,8 @@ gg_boxplot <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_col.R b/R/gg_col.R
index 45caf5ca0..e6007d251 100644
--- a/R/gg_col.R
+++ b/R/gg_col.R
@@ -1233,7 +1233,7 @@ gg_col <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1241,8 +1241,8 @@ gg_col <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_contour.R b/R/gg_contour.R
index aa91771bc..197b4bc81 100644
--- a/R/gg_contour.R
+++ b/R/gg_contour.R
@@ -1295,7 +1295,7 @@ gg_contour <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1303,8 +1303,8 @@ gg_contour <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_contour_filled.R b/R/gg_contour_filled.R
index 52e2cdaab..a1d1d0d6d 100644
--- a/R/gg_contour_filled.R
+++ b/R/gg_contour_filled.R
@@ -1289,7 +1289,7 @@ gg_contour_filled <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1297,8 +1297,8 @@ gg_contour_filled <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_crossbar.R b/R/gg_crossbar.R
index 7a9f61cb2..1b9d5f2d4 100644
--- a/R/gg_crossbar.R
+++ b/R/gg_crossbar.R
@@ -1316,7 +1316,7 @@ gg_crossbar <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1324,8 +1324,8 @@ gg_crossbar <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_density.R b/R/gg_density.R
index 271f1fb2f..3b39ca62b 100644
--- a/R/gg_density.R
+++ b/R/gg_density.R
@@ -1228,7 +1228,7 @@ gg_density <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1236,8 +1236,8 @@ gg_density <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_density_2d.R b/R/gg_density_2d.R
index 3e9646b70..af41a122a 100644
--- a/R/gg_density_2d.R
+++ b/R/gg_density_2d.R
@@ -1253,7 +1253,7 @@ gg_density_2d <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1261,8 +1261,8 @@ gg_density_2d <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_density_2d_filled.R b/R/gg_density_2d_filled.R
index 464b83c28..726356f58 100644
--- a/R/gg_density_2d_filled.R
+++ b/R/gg_density_2d_filled.R
@@ -1243,7 +1243,7 @@ gg_density_2d_filled <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1251,8 +1251,8 @@ gg_density_2d_filled <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_errorbar.R b/R/gg_errorbar.R
index 7ef269fbb..ce5c8a0a1 100644
--- a/R/gg_errorbar.R
+++ b/R/gg_errorbar.R
@@ -1313,7 +1313,7 @@ gg_errorbar <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1321,8 +1321,8 @@ gg_errorbar <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_freqpoly.R b/R/gg_freqpoly.R
index 7934cea41..85e553667 100644
--- a/R/gg_freqpoly.R
+++ b/R/gg_freqpoly.R
@@ -1229,7 +1229,7 @@ gg_freqpoly <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1237,8 +1237,8 @@ gg_freqpoly <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_hex.R b/R/gg_hex.R
index 078171e7c..b47d6d258 100644
--- a/R/gg_hex.R
+++ b/R/gg_hex.R
@@ -1253,7 +1253,7 @@ gg_hex <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1261,8 +1261,8 @@ gg_hex <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_histogram.R b/R/gg_histogram.R
index 58e39aa45..0c656bed9 100644
--- a/R/gg_histogram.R
+++ b/R/gg_histogram.R
@@ -1228,7 +1228,7 @@ gg_histogram <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1236,8 +1236,8 @@ gg_histogram <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_jitter.R b/R/gg_jitter.R
index 620bb08bd..e7733a52b 100644
--- a/R/gg_jitter.R
+++ b/R/gg_jitter.R
@@ -1227,7 +1227,7 @@ gg_jitter <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1235,8 +1235,8 @@ gg_jitter <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_label.R b/R/gg_label.R
index 5ba9578e2..63c53f98a 100644
--- a/R/gg_label.R
+++ b/R/gg_label.R
@@ -1243,7 +1243,7 @@ gg_label <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1251,8 +1251,8 @@ gg_label <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_line.R b/R/gg_line.R
index 6248fea77..99730e1b4 100644
--- a/R/gg_line.R
+++ b/R/gg_line.R
@@ -1223,7 +1223,7 @@ gg_line <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1231,8 +1231,8 @@ gg_line <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_linerange.R b/R/gg_linerange.R
index b139dfa1f..27495fe5a 100644
--- a/R/gg_linerange.R
+++ b/R/gg_linerange.R
@@ -1311,7 +1311,7 @@ gg_linerange <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1319,8 +1319,8 @@ gg_linerange <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_path.R b/R/gg_path.R
index 6caf6f0b4..18a69bedb 100644
--- a/R/gg_path.R
+++ b/R/gg_path.R
@@ -1227,7 +1227,7 @@ gg_path <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1235,8 +1235,8 @@ gg_path <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_point.R b/R/gg_point.R
index e47628c13..1db6370d2 100644
--- a/R/gg_point.R
+++ b/R/gg_point.R
@@ -1227,7 +1227,7 @@ gg_point <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1235,8 +1235,8 @@ gg_point <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_pointrange.R b/R/gg_pointrange.R
index 2165534eb..b7a829ad3 100644
--- a/R/gg_pointrange.R
+++ b/R/gg_pointrange.R
@@ -1314,7 +1314,7 @@ gg_pointrange <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1322,8 +1322,8 @@ gg_pointrange <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_polygon.R b/R/gg_polygon.R
index 601a3d715..a8a90ce91 100644
--- a/R/gg_polygon.R
+++ b/R/gg_polygon.R
@@ -1252,7 +1252,7 @@ gg_polygon <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1260,8 +1260,8 @@ gg_polygon <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_qq.R b/R/gg_qq.R
index ac73bd0e3..17e8500a4 100644
--- a/R/gg_qq.R
+++ b/R/gg_qq.R
@@ -1253,7 +1253,7 @@ gg_qq <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1261,8 +1261,8 @@ gg_qq <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_raster.R b/R/gg_raster.R
index c7f16ccdd..29b4a4d7f 100644
--- a/R/gg_raster.R
+++ b/R/gg_raster.R
@@ -1221,7 +1221,7 @@ gg_raster <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1229,8 +1229,8 @@ gg_raster <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_rect.R b/R/gg_rect.R
index 535ddc6d4..88bf17957 100644
--- a/R/gg_rect.R
+++ b/R/gg_rect.R
@@ -76,7 +76,7 @@
#' data.frame(
#' x = rep(c(2, 5, 7, 9, 12), 2),
#' y = rep(c(1, 2), each = 5),
-#' z = factor(rep(1:5, each = 2)),
+#' z = factor(c(rep(1:3, each = 3), 4)),
#' w = rep(diff(c(0, 4, 6, 8, 10, 14)), 2)
#' ) %>%
#' dplyr::mutate(
@@ -1302,7 +1302,7 @@ gg_rect <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1310,8 +1310,8 @@ gg_rect <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_ribbon.R b/R/gg_ribbon.R
index 46b47bdc6..31d27b655 100644
--- a/R/gg_ribbon.R
+++ b/R/gg_ribbon.R
@@ -1309,7 +1309,7 @@ gg_ribbon <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1317,8 +1317,8 @@ gg_ribbon <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_segment.R b/R/gg_segment.R
index f1c50633f..35d930bd2 100644
--- a/R/gg_segment.R
+++ b/R/gg_segment.R
@@ -1281,7 +1281,7 @@ gg_segment <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1289,8 +1289,8 @@ gg_segment <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_sf.R b/R/gg_sf.R
index 044723af5..64ea2f559 100644
--- a/R/gg_sf.R
+++ b/R/gg_sf.R
@@ -1131,7 +1131,7 @@ gg_sf <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1139,8 +1139,8 @@ gg_sf <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_smooth.R b/R/gg_smooth.R
index de9adcf07..48fd627b6 100644
--- a/R/gg_smooth.R
+++ b/R/gg_smooth.R
@@ -1225,7 +1225,7 @@ gg_smooth <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1233,8 +1233,8 @@ gg_smooth <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_step.R b/R/gg_step.R
index fd333c661..302cb0bdb 100644
--- a/R/gg_step.R
+++ b/R/gg_step.R
@@ -1226,7 +1226,7 @@ gg_step <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1234,8 +1234,8 @@ gg_step <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_text.R b/R/gg_text.R
index 8aa048fac..64284558e 100644
--- a/R/gg_text.R
+++ b/R/gg_text.R
@@ -1244,7 +1244,7 @@ gg_text <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1252,8 +1252,8 @@ gg_text <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_tile.R b/R/gg_tile.R
index 43e4cd2a3..bfef99e96 100644
--- a/R/gg_tile.R
+++ b/R/gg_tile.R
@@ -1227,7 +1227,7 @@ gg_tile <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1235,8 +1235,8 @@ gg_tile <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/gg_violin.R b/R/gg_violin.R
index faec33013..22e44d91e 100644
--- a/R/gg_violin.R
+++ b/R/gg_violin.R
@@ -1227,7 +1227,7 @@ gg_violin <- function(
if (col_factor) col_n <- length(levels(col_vctr))
else if (col_character) {
col_unique <- unique(col_vctr)
- col_n <- length(col_unique[!rlang::is_na(col_unique)])
+ col_n <- length(col_unique[!is.na(col_unique)])
}
else if (stat %in% c("contour_filled", "density_2d_filled")) {
col_n <- length(levels(dplyr::pull(plot_data, "level")))
@@ -1235,8 +1235,8 @@ gg_violin <- function(
if (rlang::is_null(pal)) {
if (stat %in% c("contour_filled", "density_2d_filled")) pal <- viridisLite::mako(n = col_n, direction = -1)
- else if (col_n > 5) pal <- scales::hue_pal()(col_n)
- else pal <- jumble(n = col_n)
+ else if (col_n > 4) pal <- scales::hue_pal()(col_n)
+ else pal <- guardian(n = col_n)
}
else if (rlang::is_null(names(pal))) pal <- pal[1:col_n]
diff --git a/R/pal.R b/R/pal.R
index 71f86a4a6..c6ec538a8 100644
--- a/R/pal.R
+++ b/R/pal.R
@@ -1,17 +1,15 @@
-#' Colour blind safe categorical palette with 5 colours
+#' Colour blind safe categorical palette with 4 colours
#'
-#' @description A default colour blind safe 5 colour palette used to colour a categorical variable.
+#' @description A colour blind safe categorical palette inspired by the Guardian newspaper.
#'
-#' @param n The number of colours to return. Defaults to the maximum of 5.
+#' @param n The number of colours to return. Defaults to the maximum of 4.
#'
#' @return A character vector of hex codes.
#'
#' @export
-jumble <- function(n = 5) {
- if (n > 5) rlang::abort("jumble provides a maximum of 5 colours")
- else {
- c("#2596be", "#fc7c24", "#125162", "#b82e2e", "#ecdd13")[1:n]
- }
+guardian <- function(n = 4) {
+ if (n <= 4) c("#2596be", "#fc7c24", "#6b5840", "#9c1e74")[1:n]
+ else rlang::abort("guardian provides a maximum of 4 colours")
}
#' Default colours used in the light_mode theme.
diff --git a/man/gg_rect.Rd b/man/gg_rect.Rd
index f79f0d181..f49a9501c 100644
--- a/man/gg_rect.Rd
+++ b/man/gg_rect.Rd
@@ -219,7 +219,7 @@ Create a rect ggplot with a wrapper around ggplot2::geom_rect(stat = "identity",
data.frame(
x = rep(c(2, 5, 7, 9, 12), 2),
y = rep(c(1, 2), each = 5),
- z = factor(rep(1:5, each = 2)),
+ z = factor(c(rep(1:3, each = 3), 4)),
w = rep(diff(c(0, 4, 6, 8, 10, 14)), 2)
) \%>\%
dplyr::mutate(
diff --git a/man/jumble.Rd b/man/guardian.Rd
similarity index 53%
rename from man/jumble.Rd
rename to man/guardian.Rd
index 447251026..eabc4573b 100644
--- a/man/jumble.Rd
+++ b/man/guardian.Rd
@@ -1,17 +1,17 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pal.R
-\name{jumble}
-\alias{jumble}
-\title{Colour blind safe categorical palette with 5 colours}
+\name{guardian}
+\alias{guardian}
+\title{Colour blind safe categorical palette with 4 colours}
\usage{
-jumble(n = 5)
+guardian(n = 4)
}
\arguments{
-\item{n}{The number of colours to return. Defaults to the maximum of 5.}
+\item{n}{The number of colours to return. Defaults to the maximum of 4.}
}
\value{
A character vector of hex codes.
}
\description{
-A default colour blind safe 5 colour palette used to colour a categorical variable.
+A colour blind safe categorical palette inspired by the Guardian newspaper.
}
diff --git a/vignettes/articles/1_functions_demo-Rmd.Rmd b/vignettes/articles/1_functions_demo-Rmd.Rmd
index ec67ec8e8..1997f699c 100644
--- a/vignettes/articles/1_functions_demo-Rmd.Rmd
+++ b/vignettes/articles/1_functions_demo-Rmd.Rmd
@@ -394,7 +394,7 @@ faithfuld |>
data.frame(
x = rep(c(2, 5, 7, 9, 12), 2),
y = rep(c(1, 2), each = 5),
- z = factor(rep(1:5, each = 2)),
+ z = factor(c(rep(1:3, each = 3), 4)),
w = rep(diff(c(0, 4, 6, 8, 10, 14)), 2)) |>
mutate(
xmin = x - w / 2,
diff --git a/vignettes/articles/2_functions_demo_dark-Rmd.Rmd b/vignettes/articles/2_functions_demo_dark-Rmd.Rmd
index 2e879a9d9..736624bd6 100644
--- a/vignettes/articles/2_functions_demo_dark-Rmd.Rmd
+++ b/vignettes/articles/2_functions_demo_dark-Rmd.Rmd
@@ -401,7 +401,7 @@ faithfuld |>
data.frame(
x = rep(c(2, 5, 7, 9, 12), 2),
y = rep(c(1, 2), each = 5),
- z = factor(rep(1:5, each = 2)),
+ z = factor(c(rep(1:3, each = 3), 4)),
w = rep(diff(c(0, 4, 6, 8, 10, 14)), 2)) |>
mutate(
xmin = x - w / 2,
diff --git a/vignettes/articles/3_go_further-Rmd.Rmd b/vignettes/articles/3_go_further-Rmd.Rmd
index 7209a5dca..3866abed6 100644
--- a/vignettes/articles/3_go_further-Rmd.Rmd
+++ b/vignettes/articles/3_go_further-Rmd.Rmd
@@ -119,7 +119,7 @@ p3 <- iris |>
gg_density(
x = Sepal.Length,
col = Species,
- pal = scales::alpha(jumble(), 0),
+ pal = scales::alpha(guardian(), 0),
y_labels = \(x) str_keep_seq(x, drop0trailing = TRUE),
col_legend_nrow = 2,
col_labels = \(x) str_to_sentence(x))
@@ -295,27 +295,6 @@ contrast <- function(colour) {
out
}
-p <- penguins2 |>
- group_by(sex, species) |>
- summarise(across(flipper_length_mm, \(x) mean(x, na.rm = TRUE))) |>
- gg_col(
- x = flipper_length_mm,
- y = species,
- col = sex,
- position = "dodge",
- width = 0.75)
-
-p +
- geom_text(
- aes(x = flipper_length_mm - (max(flipper_length_mm) * 0.05),
- label = round(flipper_length_mm, 0),
- !!!aes(colour = after_scale(contrast(fill)))),
- show.legend = FALSE,
- size = 3.53,
- position = position_dodge(width = 0.75))
-```
-
-```{r}
d <- mtcars |>
corrr::correlate() |>
corrr::stretch() |>
@@ -340,3 +319,26 @@ d |>
show.legend = FALSE,
size = 3.53)
```
+
+```{r}
+p <- penguins2 |>
+ group_by(sex, species) |>
+ summarise(across(flipper_length_mm, \(x) mean(x, na.rm = TRUE))) |>
+ gg_col(
+ x = flipper_length_mm,
+ y = species,
+ col = sex,
+ position = "dodge",
+ width = 0.75,
+ colour = NA)
+
+p +
+ geom_text(
+ aes(x = flipper_length_mm - (max(flipper_length_mm) * 0.05),
+ label = round(flipper_length_mm, 0),
+ !!!aes(colour = after_scale(contrast(fill)))),
+ show.legend = FALSE,
+ size = 3.53,
+ position = position_dodge(width = 0.75))
+```
+
diff --git a/vignettes/articles/4_extensions-Rmd.Rmd b/vignettes/articles/4_extensions-Rmd.Rmd
index a6646cc0e..7f42da1c7 100644
--- a/vignettes/articles/4_extensions-Rmd.Rmd
+++ b/vignettes/articles/4_extensions-Rmd.Rmd
@@ -292,13 +292,14 @@ The ggnewscale package enables multiple colour scales.
penguins2 |>
gg_blank(x = flipper_length_mm,
y = body_mass_g) +
- geom_point(aes(colour = bill_length_mm), data = penguins2 |> filter(species == "Gentoo")) +
+ geom_point(aes(colour = bill_length_mm),
+ data = penguins2 |> filter(species == "Gentoo")) +
scale_color_viridis_c(option = "G", direction = -1) +
labs(colour = "Gentoo\nBill length (mm)") +
ggnewscale::new_scale_colour() +
geom_point(aes(x = flipper_length_mm, y = body_mass_g, colour = species),
data = penguins2 |> filter(species != "Gentoo")) +
- scale_color_manual(values = jumble()[c(2,4)]) +
+ scale_color_manual(values = guardian()[c(4,2)]) +
labs(colour = "Species")
```
@@ -405,7 +406,7 @@ penguins2 |>
title = "***Pygoscelis*** **penguin** bill lengths and depths",
subtitle = "**Adelie**,
**Chinstrap**,
- *and* **Gentoo**",
+ *and* **Gentoo**",
x_labels = \(x) glue::glue("_{x}_"),
y_labels = \(x) glue::glue("_{x}_"),
col_labels = \(x) glue::glue("_{x}_"),
diff --git a/vignettes/ggblanket.Rmd b/vignettes/ggblanket.Rmd
index 311deac3e..a15d57ed2 100644
--- a/vignettes/ggblanket.Rmd
+++ b/vignettes/ggblanket.Rmd
@@ -359,7 +359,7 @@ p1 <- ggplot2::economics |>
gg_line(
x = date,
y = unemploy,
- pal = jumble()[1],
+ pal = guardian()[1],
x_title = "",
y_title = "Unemployment",
y_include = 0,
@@ -367,26 +367,26 @@ p1 <- ggplot2::economics |>
x_breaks = scales::breaks_width("3 months"),
title = "gg_line + geom_point",
theme = light_mode(title_face = "plain")) +
- geom_point(colour = jumble()[2])
+ geom_point(colour = guardian()[2])
p2 <- ggplot2::economics |>
slice_min(order_by = date, n = 10) |>
gg_point(
x = date,
y = unemploy,
- pal = jumble()[2],
+ pal = guardian()[2],
x_title = "",
y_title = "Unemployment",
y_include = 0,
x_breaks = scales::breaks_width("3 months"),
title = "gg_point + geom_line",
theme = light_mode(title_face = "plain")) +
- geom_line(colour = jumble()[1], linewidth = 1)
+ geom_line(colour = guardian()[1], linewidth = 1)
p1 + p2
```
-2. If some geom layers have a `col` aesthetic and some do not, then a `gg_*` function _should_ be chosen that has a `col` argument in it. This will enable ggblanket legend placement and access to `col_*` arguments. It is also a more reliable approach.
+2. If some geom layers have a `col` aesthetic and some do not, then a `gg_*` function _should_ be chosen that has a `col` argument in it. This will enable ggblanket legend placement and access to `col_*` arguments. It is also a more reliable approach. If later layers do not require the `col` aesthetic, then the `inheit.aes = FALSE` argument should be used.
3. In some situations, `gg_blank` may be required.
@@ -410,7 +410,10 @@ p1 <- d |>
x_include = max(d$upper),
width = 0.75,
col_legend_place = "n") +
- geom_errorbar(aes(xmin = lower, xmax = upper), colour = "black", width = 0.1)
+ geom_errorbar(aes(xmin = lower, xmax = upper, y = species),
+ inherit.aes = FALSE,
+ colour = "black",
+ width = 0.1)
p2 <- d |>
gg_blank(
@@ -592,7 +595,7 @@ p1 + p2
ggblanket uses different defaults for colouring. The default `pal` is:
* `steelblue` for where there is no `col` variable
-* `ggblanket::jumble` for a discrete `col` variable with 5 or less levels (or unique values if a character). Testing suggests this is safe for colour blindness.
+* `ggblanket::guardian` for a discrete `col` variable with 3 or less levels (or unique values if a character). Testing suggests this is safe for colour blindness.
* `scales::hue_pal` for a discrete `col` variable with more than 5 levels (or unique values if not ordered).
* `viridis::mako` reversed for a continuous `col` variable