| #' Use [set_font_size()] to set global default font sizes. | #' Use [set_font_size()] to set global default font sizes. | ||||
| #' @param text_size Font size of the plot text, default is 5. | #' @param text_size Font size of the plot text, default is 5. | ||||
| #' @param title_size Font size of the plot title, default is 17. | #' @param title_size Font size of the plot title, default is 17. | ||||
| #' @param cell_width Width of a cell, default is 1. | |||||
| #' @param cell_height Height of a cell, default is 1. | |||||
| #' @param ease_default Default aes easing function. See [tweenr::display_ease()] | #' @param ease_default Default aes easing function. See [tweenr::display_ease()] | ||||
| #' for more options. The tidyexplain default value is `sine-in-out`. | #' for more options. The tidyexplain default value is `sine-in-out`. | ||||
| #' @param ease_other Additional aes easing options, specified as a named list. | #' @param ease_other Additional aes easing options, specified as a named list. | ||||
| color_missing = NULL, | color_missing = NULL, | ||||
| color_fun = NULL, | color_fun = NULL, | ||||
| text_color = NULL, | text_color = NULL, | ||||
| cell_width = NULL, | |||||
| cell_height = NULL, | |||||
| ... | ... | ||||
| ){ | ){ | ||||
| enter_name <- if (!missing(enter)) rlang::quo_name(rlang::enquo(enter)) | enter_name <- if (!missing(enter)) rlang::quo_name(rlang::enquo(enter)) | ||||
| color_missing = color_missing, | color_missing = color_missing, | ||||
| color_fun = color_fun, | color_fun = color_fun, | ||||
| text_color = text_color, | text_color = text_color, | ||||
| cell_width = cell_width, | |||||
| cell_height = cell_height, | |||||
| ... | ... | ||||
| ) | ) | ||||
| ao <- purrr::compact(ao) | ao <- purrr::compact(ao) | ||||
| ao$color_missing <- ao$color_missing %||% get_anim_opt("color_missing") | ao$color_missing <- ao$color_missing %||% get_anim_opt("color_missing") | ||||
| ao$color_fun <- ao$color_fun %||% get_anim_opt("color_fun") | ao$color_fun <- ao$color_fun %||% get_anim_opt("color_fun") | ||||
| ao$text_color <- ao$text_color %||% get_anim_opt("text_color") | ao$text_color <- ao$text_color %||% get_anim_opt("text_color") | ||||
| ao$cell_width <- ao$cell_width %||% get_anim_opt("cell_width") | |||||
| ao$cell_height <- ao$cell_height %||% get_anim_opt("cell_height") | |||||
| ao | ao | ||||
| } | } |
| d <- d %>% mutate(.item_id = .id) | d <- d %>% mutate(.item_id = .id) | ||||
| } | } | ||||
| ggplot(d, aes(x = .x, y = .y, fill = .color, alpha = .alpha, group = .item_id)) + | |||||
| geom_tile(width = 0.9, height = 0.9) + | |||||
| width <- ao$cell_width %||% 1 | |||||
| height <- ao$cell_height %||% 1 | |||||
| ggplot(d, aes(x = .x * width, y = .y * height, fill = .color, alpha = .alpha, | |||||
| group = .item_id)) + | |||||
| geom_tile(width = 0.9 * width, height = 0.9 * height) + | |||||
| coord_equal() + | coord_equal() + | ||||
| geom_text(data = d %>% filter(!is.na(.val)), aes(label = .val, color = .textcolor), | geom_text(data = d %>% filter(!is.na(.val)), aes(label = .val, color = .textcolor), | ||||
| family = ao$text_family, size = text_size) + | family = ao$text_family, size = text_size) + |
| color_other = "#d0d0d0", | color_other = "#d0d0d0", | ||||
| color_missing = "#ffffff", | color_missing = "#ffffff", | ||||
| color_fun = scales::brewer_pal(type = "qual", "Set1"), | color_fun = scales::brewer_pal(type = "qual", "Set1"), | ||||
| text_color = NA | |||||
| text_color = NA, | |||||
| cell_width = 1, | |||||
| cell_height = 1 | |||||
| ) | ) | ||||
| exit = NULL, text_family = NULL, title_family = NULL, | exit = NULL, text_family = NULL, title_family = NULL, | ||||
| text_size = NULL, title_size = NULL, color_header = NULL, | text_size = NULL, title_size = NULL, color_header = NULL, | ||||
| color_other = NULL, color_missing = NULL, color_fun = NULL, | color_other = NULL, color_missing = NULL, color_fun = NULL, | ||||
| text_color = NULL, ...) | |||||
| text_color = NULL, cell_width = NULL, cell_height = NULL, ...) | |||||
| set_anim_options(anim_opts = anim_options()) | set_anim_options(anim_opts = anim_options()) | ||||
| } | } | ||||
| \item{text_color}{Color of the text of the cells, default is a black or | \item{text_color}{Color of the text of the cells, default is a black or | ||||
| white, based on the background color of the cell.} | white, based on the background color of the cell.} | ||||
| \item{cell_width}{Width of a cell, default is 1.} | |||||
| \item{cell_height}{Height of a cell, default is 1.} | |||||
| \item{anim_opts}{An \code{\link[=anim_options]{anim_options()}} options list.} | \item{anim_opts}{An \code{\link[=anim_options]{anim_options()}} options list.} | ||||
| } | } | ||||
| \description{ | \description{ |
| Use \code{\link[=set_font_size]{set_font_size()}} to set global default font sizes.} | Use \code{\link[=set_font_size]{set_font_size()}} to set global default font sizes.} | ||||
| \item{text_size}{Font size of the plot text, default is 5.} | \item{text_size}{Font size of the plot text, default is 5.} | ||||
| \item{title_size}{Font size of the plot title, default is 17.} | \item{title_size}{Font size of the plot title, default is 17.} | ||||
| \item{cell_width}{Width of a cell, default is 1.} | |||||
| \item{cell_height}{Height of a cell, default is 1.} | |||||
| \item{ease_default}{Default aes easing function. See \code{\link[tweenr:display_ease]{tweenr::display_ease()}} | \item{ease_default}{Default aes easing function. See \code{\link[tweenr:display_ease]{tweenr::display_ease()}} | ||||
| for more options. The tidyexplain default value is \code{sine-in-out}.} | for more options. The tidyexplain default value is \code{sine-in-out}.} | ||||
| \item{ease_other}{Additional aes easing options, specified as a named list. | \item{ease_other}{Additional aes easing options, specified as a named list. |