Newly tracked file
R/palette_explorer.R
changed.
Newly tracked file
R/get_brewer_pal.R
changed.
Other files ignored by Codecov
man/get_brewer_pal.Rd
has changed.
man/palette_explorer.Rd
has changed.
97 | 97 | ||
98 | 98 | #' Explore color palettes |
|
99 | 99 | #' |
|
100 | - | #' \code{palette_explorer()} starts an interactive tool shows all Color Brewer and viridis palettes, where the number of colors can be adjusted as well as the constrast range. Categorical (qualitative) palettes can be stretched when the number of colors exceeds the number of palette colors. Output code needed to get the desired color values is generated. Finally, all colors can be tested for color blindness. The data.frame \code{tmap.pal.info} is similar to \code{\link[RColorBrewer:RColorBrewer]{brewer.pal.info}}, but extended with the color palettes from viridis. |
|
100 | + | #' \code{palette_explorer()} starts an interactive tool shows all Color Brewer and viridis palettes, where the number of colors can be adjusted as well as the constrast range. Categorical (qualitative) palettes can be stretched when the number of colors exceeds the number of palette colors. Output code needed to get the desired color values is generated. Finally, all colors can be tested for color blindness. The data.frame \code{tmap.pal.info} is similar to \code{\link[RColorBrewer:ColorBrewer]{brewer.pal.info}}, but extended with the color palettes from viridis. |
|
101 | 101 | #' @export |
|
102 | 102 | #' @importFrom grDevices col2rgb |
|
103 | 103 | #' @importFrom dichromat dichromat |
105 | 105 | #' @name palette_explorer |
|
106 | 106 | #' @rdname palette_explorer |
|
107 | 107 | #' @example ./examples/palette_explorer.R |
|
108 | - | #' @seealso \code{\link{get_brewer_pal}}, \code{\link[dichromat:dichromat]{dichromat}}, \code{\link[RColorBrewer:RColorBrewer]{RColorBrewer}} |
|
108 | + | #' @seealso \code{\link{get_brewer_pal}}, \code{\link[dichromat:dichromat]{dichromat}}, \code{\link[RColorBrewer:ColorBrewer]{RColorBrewer}} |
|
109 | 109 | #' @references \url{http://www.color-blindness.com/types-of-color-blindness/} |
|
110 | 110 | palette_explorer <- function() { |
|
111 | 111 | if (!requireNamespace("shiny")) stop("shiny package needed for this function to work. Please install it.", call. = FALSE) |
1 | 1 | #' Get and plot a (modified) Color Brewer palette |
|
2 | 2 | #' |
|
3 | - | #' Get and plot a (modified) palette from Color Brewer. In addition to the base function \code{\link[RColorBrewer:RColorBrewer]{brewer.pal}}, a palette can be created for any number of classes. The contrast of the palette can be adjusted for sequential and diverging palettes. For categorical palettes, intermediate colors can be generated. An interactive tool that uses this function is \code{\link{palette_explorer}}. |
|
3 | + | #' Get and plot a (modified) palette from Color Brewer. In addition to the base function \code{\link[RColorBrewer:ColorBrewer]{brewer.pal}}, a palette can be created for any number of classes. The contrast of the palette can be adjusted for sequential and diverging palettes. For categorical palettes, intermediate colors can be generated. An interactive tool that uses this function is \code{\link{palette_explorer}}. |
|
4 | 4 | #' |
|
5 | 5 | #' The default contrast of the palette depends on the number of colors, \code{n}, in the following way. The default contrast is maximal, so \code{(0, 1)}, when \code{n = 9} for sequential palettes and \code{n = 11} for diverging palettes. The default contrast values for smaller values of \code{n} can be extracted with some R magic: \code{sapply(1:9, tmaptools:::default_contrast_seq)} for sequential palettes and \code{sapply(1:11, tmaptools:::default_contrast_div)} for diverging palettes. |
|
6 | 6 | #' |
|
7 | - | #' @param palette name of the color brewer palette. Run \code{\link{palette_explorer}} or see \code{\link[RColorBrewer:RColorBrewer]{brewer.pal}} for options. |
|
7 | + | #' @param palette name of the color brewer palette. Run \code{\link{palette_explorer}} or see \code{\link[RColorBrewer:ColorBrewer]{brewer.pal}} for options. |
|
8 | 8 | #' @param n number of colors |
|
9 | 9 | #' @param contrast a vector of two numbers between 0 and 1 that defines the contrast range of the palette. Applicable to sequential and diverging palettes. For sequential palettes, 0 stands for the leftmost color and 1 the rightmost color. For instance, when \code{contrast=c(.25, .75)}, then the palette ranges from 1/4 to 3/4 of the available color range. For diverging palettes, 0 stands for the middle color and 1 for both outer colors. If only one number is provided, the other number is set to 0. The default value depends on \code{n}. See details. |
|
10 | 10 | #' @param stretch logical that determines whether intermediate colors are used for a categorical palette when \code{n} is greater than the number of available colors. |
Files | Coverage |
---|---|
R | 0.00% |
Project Totals (20 files) | 0.00% |