-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update `df_covid` (#1) * Update package data * Add versioning to NEWS.md and DESCRIPTION * Fix na values (#5) * Update `df_covid` (#1) (#2) * Update package data * Add versioning to NEWS.md and DESCRIPTION * fixing for NA values * fixing for NA values Co-authored-by: Seth Caldwell <caldwellst@gmail.com> * Update NEWS.md (#6) * versioning (#7) * Hjust y labels (#9) * Update y-axis label justification * Update y-axis label justification * Remove deprecated argument from element_line * Update tests * Move ultra-light to last option in multicolor palette * Implement display_pal * Update README links * Address comments --------- Co-authored-by: Rawa Ganjani <rawaomer@outlook.com>
- Loading branch information
1 parent
c90824b
commit 697174f
Showing
35 changed files
with
473 additions
and
262 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,6 @@ | |
^README\.Rmd$ | ||
^\.Rproj\.user$ | ||
^\.github$ | ||
^\.pre-commit-config\.yaml$ | ||
^codecov\.yml$ | ||
^data-raw$ | ||
^gghdx\.Rproj$ |
This file was deleted.
Oops, something went wrong.
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,68 @@ | ||
#' Display HDX palette | ||
#' | ||
#' Displays the HDX color palettes. By default, shows all values for all | ||
#' palettes. You can change the number of values for each palette or only | ||
#' show a subset of the available palettes (from `hdx_pal_...()`). | ||
#' | ||
#' @param n Number of colors for each palette to show. | ||
#' @param palette Character vector of palettes to show. | ||
#' | ||
#' @return Plot of HDX color palettes. | ||
#' @export | ||
hdx_display_pal <- function( | ||
n = NULL, | ||
palette = c("discrete", "gray", "mint", "sapphire", "tomato") | ||
) { | ||
# check the palette argument is correct | ||
palette <- rlang::arg_match( | ||
arg = palette, | ||
multiple = TRUE | ||
) | ||
|
||
pal_funs <- list( | ||
discrete = hdx_pal_discrete(), | ||
gray = hdx_pal_gray(), | ||
mint = hdx_pal_mint(), | ||
sapphire = hdx_pal_sapphire(), | ||
tomato = hdx_pal_tomato() | ||
) | ||
|
||
purrr::map( | ||
.x = palette, | ||
.f = \(pal) { | ||
pal_fun <- pal_funs[[pal]] | ||
if (is.null(n)) { | ||
n <- attributes(pal_fun)$max_n | ||
} | ||
|
||
data.frame( | ||
palette = pal, | ||
value = pal_fun(n), | ||
idx = 1:n | ||
) | ||
} | ||
) %>% | ||
purrr::list_rbind() %>% | ||
ggplot2::ggplot( | ||
ggplot2::aes( | ||
x = idx, | ||
y = palette, | ||
fill = I(value) | ||
) | ||
) + | ||
ggplot2::geom_tile( | ||
color = "white", | ||
lwd = 1 | ||
) + | ||
theme_hdx() + | ||
ggplot2::theme( | ||
panel.grid = ggplot2::element_blank(), | ||
axis.line = ggplot2::element_blank(), | ||
axis.text.x = ggplot2::element_blank() | ||
) + | ||
ggplot2::labs( | ||
x = "", | ||
y = "", | ||
title = "gghdx palettes" | ||
) | ||
} |
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
Oops, something went wrong.