From 49d38796bb8ba843fe588876700d1fe82d7b1462 Mon Sep 17 00:00:00 2001
From: Michael McCarthy <51542091+mccarthy-m-g@users.noreply.github.com>
Date: Thu, 19 Sep 2024 11:57:20 -0700
Subject: [PATCH 1/3] rename files
---
R/{data.R => included-palettes.R} | 0
R/{colour.R => pal_colour.R} | 0
R/{palette.R => pal_palette.R} | 0
3 files changed, 0 insertions(+), 0 deletions(-)
rename R/{data.R => included-palettes.R} (100%)
rename R/{colour.R => pal_colour.R} (100%)
rename R/{palette.R => pal_palette.R} (100%)
diff --git a/R/data.R b/R/included-palettes.R
similarity index 100%
rename from R/data.R
rename to R/included-palettes.R
diff --git a/R/colour.R b/R/pal_colour.R
similarity index 100%
rename from R/colour.R
rename to R/pal_colour.R
diff --git a/R/palette.R b/R/pal_palette.R
similarity index 100%
rename from R/palette.R
rename to R/pal_palette.R
From b700f144dde52c33cf6b59d5a23ddd95cb918b7d Mon Sep 17 00:00:00 2001
From: Michael McCarthy <51542091+mccarthy-m-g@users.noreply.github.com>
Date: Thu, 19 Sep 2024 12:15:46 -0700
Subject: [PATCH 2/3] Preserve palette order in `pal_palette()` objects
---
NEWS.md | 2 ++
R/plot.R | 4 ++++
2 files changed, 6 insertions(+)
diff --git a/NEWS.md b/NEWS.md
index adcbe14..5731c23 100644
--- a/NEWS.md
+++ b/NEWS.md
@@ -2,6 +2,8 @@
- Included five new colour palette sets with the package: Cartography palettes (`discrete_palettes`, `sequential_palettes`, `diverging_palettes`), Performance palettes (`performance_palettes`), and Palmer penguins palettes (`penguin_palettes`).
+- When plotting colour palettes with `plot()`, the order of facets now matches the order of palettes in `pal_palette()` objects.
+
# palettes 0.2.1
This is a small patch release that applies some internal fixes for the `scale_()` functions, due to a breaking change in ggplot2 v3.5.0 that deprecated the `scale_name` argument in `ggplot2::continuous_scale()`, `ggplot2::discrete_scale()` and `ggplot2::binned_scale()`. The "gt" vignette has also been updated to reflect changes to the `gt::data_color()` function in gt v0.9.0.
diff --git a/R/plot.R b/R/plot.R
index 5dd10b5..72e6785 100644
--- a/R/plot.R
+++ b/R/plot.R
@@ -74,6 +74,10 @@ plot_colour <- function(
x <- pal_ramp(x, n, direction, space, interpolate)
x <- tibble::as_tibble(x)
+ # The order of palettes in pal_palette() objects should be preserved.
+ if ("palette" %in% colnames(x)) {
+ x$palette <- factor(x$palette, levels = unique(x$palette))
+ }
# When the same colour is repeated in a pal_colour() or pal_palette() object
# it needs a unique position identifier in order to be plotted in the same
# order as it appears in the vector.
From 491dca28a397a2e7f6a0b1091dc0a6b59f329ee9 Mon Sep 17 00:00:00 2001
From: Michael McCarthy <51542091+mccarthy-m-g@users.noreply.github.com>
Date: Thu, 19 Sep 2024 14:10:50 -0700
Subject: [PATCH 3/3] refine table styling
---
vignettes/articles/made-with-palettes.Rmd | 27 +++++++++++++++++------
1 file changed, 20 insertions(+), 7 deletions(-)
diff --git a/vignettes/articles/made-with-palettes.Rmd b/vignettes/articles/made-with-palettes.Rmd
index ff64398..6995578 100644
--- a/vignettes/articles/made-with-palettes.Rmd
+++ b/vignettes/articles/made-with-palettes.Rmd
@@ -13,15 +13,16 @@ library(gt)
library(fontawesome)
palettes:::made_with_palettes |>
- rename(description = title) |>
+ rename(description = title, links = gh_url) |>
gt(id = "one") |>
cols_label(
package = md("**Package**"),
+ links = md("**Links**"),
description = md("**Description**"),
authors = md("**Author**")
) |>
fmt_url(
- columns = gh_url,
+ columns = links,
label = html(fontawesome::fa("github")),
color = "#0d6efd",
show_underline = FALSE
@@ -34,30 +35,42 @@ palettes:::made_with_palettes |>
) |>
sub_missing() |>
cols_merge(
- columns = c(package, gh_url, cran_url),
- pattern = "{2} \u2002 {3} \u2002 {1}"
+ columns = c(links, cran_url),
+ pattern = "{1} \u2006 {2}"
) |>
# cols_width(
# package ~ pct(25),
# title ~ pct(40),
# authors ~ pct(35)
# ) |>
+ tab_style(
+ style = cell_text(whitespace = "nowrap"),
+ locations = cells_body(columns = links)
+ ) |>
tab_options(
table.width = pct(100),
table.font.size = "100%"
) |>
opt_css(
css = "
+ table {
+ hyphens: none !important;
+ }
+
#one [id='Package'] {
- width: 25%;
+ width: 20%;
}
#one [id='Description'] {
- width: 50%;
+ width: 40%;
}
#one [id='Author'] {
- width: 25%;
+ width: 20%;
+ }
+
+ #one [id='Links'] {
+ width: 20%;
}
#one svg {