-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from DataScienceScotland/sg-palettes
Add SG colour palettes
- Loading branch information
Showing
44 changed files
with
639 additions
and
266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#' @title Create \code{gt} table of colour palette | ||
#' | ||
#' @param pal Named vector of colour palette; | ||
#' e.g. \code{sgplot::sg_colour_palettes[["main"]]} | ||
#' | ||
#' @return An object of class \code{gt_tbl}. | ||
|
||
colour_table <- function(pal) { | ||
|
||
tibble::enframe(pal) |> | ||
dplyr::mutate(example = "") |> | ||
dplyr::mutate(value = factor( | ||
pal, | ||
ordered = TRUE, | ||
levels = unname(pal) | ||
)) |> | ||
gt::gt() |> | ||
gt::data_color( | ||
columns = .data$value, | ||
target_columns = .data$example, | ||
fn = scales::col_factor( | ||
palette = pal, | ||
domain = NULL | ||
) | ||
) |> | ||
gt::cols_width( | ||
name ~ gt::px(110), | ||
value ~ gt::px(100), | ||
example ~ gt::px(150) | ||
) |> | ||
gt::cols_align( | ||
align = "left", | ||
columns = dplyr::everything() | ||
) |> | ||
gt::cols_label( | ||
name = "Colour name", | ||
value = "Hex code", | ||
example = "Example of colour" | ||
) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#' @keywords internal | ||
"_PACKAGE" | ||
|
||
## usethis namespace: start | ||
#' @importFrom rlang .data | ||
## usethis namespace: end | ||
NULL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.