### Full cols4all GUI and table example Source: https://cols4all.github.io/cols4all-R/reference/c4a_gui.html Demonstrates launching the GUI and using the table function with various options, provided all necessary packages are installed and the session is interactive. ```R if (requireNamespace("shiny") && requireNamespace("shinyjs") && requireNamespace("kableExtra") && requireNamespace("colorblindcheck") && interactive()) { c4a_gui() # categorical palettes with maximum number of colors c4a_table(type = "cat") # sort sequential palettes by hue c4a_table(type = "seq", n = 7, sort = "H") # sort sequential palettes by hue type (how many hues are used) c4a_table(type = "seq", n = 5, sort = "hues") } ``` -------------------------------- ### Example: Plotting Brewer Set 1 Palette Source: https://cols4all.github.io/cols4all-R/reference/c4a_plot.html Demonstrates plotting the 'brewer.set1' palette with one row. ```R c4a_plot("brewer.set1", nrows=1) ``` -------------------------------- ### Install cols4all from CRAN Source: https://cols4all.github.io/cols4all-R/index.html Install the cols4all package from CRAN, including its dependencies. ```R install.packages("cols4all", dependencies = TRUE) ``` -------------------------------- ### Install cols4all Development Version Source: https://cols4all.github.io/cols4all-R/index.html Install the development version of the cols4all package from GitHub using the remotes package. ```R install.packages("remotes") remotes::install_github("cols4all/cols4all-R", dependencies = TRUE) ``` -------------------------------- ### Install cols4all R Package Source: https://cols4all.github.io/cols4all-R/articles/01_paper.html Install the cols4all R package to access interactive tools for color palette analysis. This is the primary method for obtaining the package. ```r install.packages("cols4all") ``` -------------------------------- ### Get or set global options Source: https://cols4all.github.io/cols4all-R/reference/c4a_options.html The primary interface for interacting with package configuration. ```R c4a_options(...) ``` -------------------------------- ### Example: Plotting 'tol.pu_gn' Palette with CVD Simulation Source: https://cols4all.github.io/cols4all-R/reference/c4a_plot.html Demonstrates plotting the 'tol.pu_gn' palette including color-blindness simulations. ```R c4a_plot_cvd("tol.pu_gn") ``` -------------------------------- ### Example: Plotting 'greens' Palette with CVD Simulation Source: https://cols4all.github.io/cols4all-R/reference/c4a_plot.html Demonstrates plotting the 'greens' palette including color-blindness simulations. ```R c4a_plot_cvd("greens") ``` -------------------------------- ### Example: Plotting Brewer Set 1 with CVD Simulation Source: https://cols4all.github.io/cols4all-R/reference/c4a_plot.html Demonstrates plotting the 'brewer.set1' palette including color-blindness simulations. ```R c4a_plot_cvd("brewer.set1") ``` -------------------------------- ### Example: Plotting Brewer Set 1 with Hex Codes Source: https://cols4all.github.io/cols4all-R/reference/c4a_plot.html Demonstrates plotting the 'brewer.set1' palette and displaying its hex codes, with one row. ```R c4a_plot_hex("brewer.set1", nrows=1) ``` -------------------------------- ### Get Palette Overview Source: https://cols4all.github.io/cols4all-R/reference/c4a_palettes.html Provides a summary table of the number of palettes available per series and type. ```APIDOC ## GET /api/overview ### Description Generates an overview table summarizing the count of color palettes for each series and type combination available in the cols4all package. ### Method GET ### Endpoint /api/overview ### Query Parameters - **return.matrix** (boolean) - Optional - If TRUE, returns only a matrix of counts. Defaults to FALSE (returns a data frame with additional info). - **zero.count.as.NA** (boolean) - Optional - If TRUE, zero counts are returned as NA. Defaults to FALSE. ### Response #### Success Response (200) - **overview** (object or matrix) - A table or matrix showing palette counts per series and type. #### Response Example ```json { "overview": [ { "series": "viridis", "type": "seq", "count": 5 }, { "series": "magma", "type": "seq", "count": 5 } ] } ``` ``` -------------------------------- ### Retrieve palette scores Source: https://cols4all.github.io/cols4all-R/reference/c4a_scores.html Examples of retrieving scores for a single palette and batch processing multiple palettes. ```R c4a_scores("blues3") pals = c4a_palettes(type = "cat") scores_cat7 = t(sapply(pals, c4a_scores, n = 7)) head(scores_cat7) ``` -------------------------------- ### Example: Plotting a Met Bivc Palette Source: https://cols4all.github.io/cols4all-R/reference/c4a_plot.html Plots a specific bivariate color palette from the 'met' dataset. ```R c4a_plot(.P$met$bivc$monet) ``` -------------------------------- ### Example: Plotting a cols4all Bigv Palette Source: https://cols4all.github.io/cols4all-R/reference/c4a_plot.html Plots a specific bivariate color palette from cols4all, specifying 5 colors. ```R c4a_plot(.P$cols4all$bivg$gn_bivg, n = 5) ``` -------------------------------- ### Get an overview of palette counts Source: https://cols4all.github.io/cols4all-R/reference/c4a_palettes.html Provides a summary table showing the number of palettes per series and type. ```R c4a_overview() ``` -------------------------------- ### Launch Interactive Palette GUI Source: https://cols4all.github.io/cols4all-R/articles/02_paletteer.html Start the interactive graphical user interface (GUI) for exploring color palettes. This tool allows for filtering and sorting palettes based on various criteria. ```r c4a_gui() ``` -------------------------------- ### Example: Plotting a cols4all Bivs Palette Source: https://cols4all.github.io/cols4all-R/reference/c4a_plot.html Plots a specific bivariate color palette from cols4all, specifying 5 colors. ```R c4a_plot(.P$cols4all$bivs$pu_gn_bivs, n = 5) ``` -------------------------------- ### Overview of Available Palettes Source: https://cols4all.github.io/cols4all-R/articles/02_paletteer.html Get an overview of the number of available palettes from 'paletteer' in a matrix format. This helps in understanding the distribution of palettes by type and source. ```r (m <- c4a_overview(return.matrix = TRUE)) ``` -------------------------------- ### Example: Plotting a cols4all Bivd Palette Source: https://cols4all.github.io/cols4all-R/reference/c4a_plot.html Plots a specific bivariate color palette from cols4all, specifying 5 colors. ```R c4a_plot(.P$cols4all$bivd$pu_gn_bivd, n = 5) ``` -------------------------------- ### Get Available Series Source: https://cols4all.github.io/cols4all-R/reference/c4a_palettes.html Lists the available series for organizing color palettes. Can return results as a data frame. ```APIDOC ## GET /api/series ### Description Lists the available series used to organize color palettes in the cols4all package. The output can be formatted as a data frame. ### Method GET ### Endpoint /api/series ### Query Parameters - **type** (string) - Optional - Filter series by palette type: 'all', 'cat', 'seq', 'div', 'cyc'. Defaults to 'all'. - **as.data.frame** (boolean) - Optional - Whether to return the result as a data frame with descriptions. Defaults to TRUE. ### Response #### Success Response (200) - **series** (array of objects or strings) - A list of series names or data frame rows describing each series. #### Response Example ```json { "series": [ { "name": "viridis", "description": "Perceptually uniform sequential colormap" }, { "name": "magma", "description": "Perceptually uniform sequential colormap" } ] } ``` ``` -------------------------------- ### Get Colors from a Palette and Missing Value Color Source: https://cols4all.github.io/cols4all-R/index.html Use `c4a` to retrieve a specified number of colors from a named palette (e.g., 'hcl.purple_green'). Use `c4a_na` to get the specific color designated for missing values within that palette. ```R # select purple green palette from the hcl series: c4a("hcl.purple_green", 11) #> [1] "#492050" "#82498C" "#B574C2" "#D2A9DB" "#E8D4ED" "#F1F1F1" "#C8E1C9" #> [8] "#91C392" "#4E9D4F" "#256C26" "#023903" # get the associated color for missing values c4a_na("hcl.purple_green") #> [1] "#BABABA" ``` -------------------------------- ### Get and plot a color palette Source: https://cols4all.github.io/cols4all-R/reference/c4a.html Retrieves colors from the 'brewer.set3' palette and plots them. Ensure the 'c4a_plot_hex' function is available for plotting. ```R set3 <- c4a("brewer.set3") c4a_plot_hex(set3, nrows = 1) ``` -------------------------------- ### Get Available Palette Names and Series Source: https://cols4all.github.io/cols4all-R/reference/c4a_palettes.html Lists all available cols4all color palettes, organized by series and functional type. Use `.P` for interactive browsing in an IDE. ```R c4a_palettes( type = c("all", "cat", "seq", "div", "cyc", "bivs", "bivc", "bivd", "bivg"), series = NULL, full.names = TRUE ) ``` ```R c4a_series(type = c("all", "cat", "seq", "div", "cyc"), as.data.frame = TRUE) ``` ```R c4a_types(series = NULL, as.data.frame = TRUE) ``` ```R c4a_overview(return.matrix = FALSE, zero.count.as.NA = FALSE) ``` ```R .P ``` -------------------------------- ### Get information from a cols4all palette Source: https://cols4all.github.io/cols4all-R/reference/c4a_scores.html Retrieves detailed information and scores for a specified color palette from the cols4all package. ```APIDOC ## GET /api/c4a_scores ### Description Retrieves information and scores for a cols4all color palette. ### Method GET ### Endpoint /api/c4a_scores ### Parameters #### Query Parameters - **palette** (string) - Optional - Name of the palette. - **type** (string) - Optional - Type of palettes (if palette is not specified). - **series** (string) - Optional - Series name (if palette is not specified). - **n** (integer) - Optional - Number of colors. Defaults to NA. - **no.match** (string) - Optional - Action to take if no match is found. Options: "message", "error", "null". Defaults to "message". - **verbose** (boolean) - Optional - Whether to print messages. Defaults to TRUE. ### Response #### Success Response (200) - **name** (string) - Name of the palette. - **series** (string) - Series the palette belongs to. - **fullname** (string) - Full name of the palette. - **type** (string) - Type of the palette (e.g., sequential, categorical). - **palette** (array of strings) - The colors in the palette. - **na** (string) - The color used for NA values. - **nmax** (integer) - Maximum number of colors available in the palette. - **reverse** (boolean) - TRUE if the palette name has a "-" prefix, indicating reversal. ### Request Example ```json { "palette": "blues3", "n": 7 } ``` ### Response Example ```json { "name": "blues3", "series": "hcl", "fullname": "hcl.blues3", "type": "seq", "palette": ["#E5F5F9", "#C7EDF0", "#99D5C9", "#66C2A5", "#45A586", "#238B67", "#0C4534"], "na": "#FFFFFF", "nmax": 7, "reverse": false } ``` ``` -------------------------------- ### Retrieve palette colors and missing value handling Source: https://cols4all.github.io/cols4all-R/reference/c4a.html Get specific colors for a palette and the designated color for missing values. ```R c4a("carto.safe", 7) ``` ```R c4a_na("carto.safe") ``` -------------------------------- ### Get Available Palette Names Source: https://cols4all.github.io/cols4all-R/reference/c4a_palettes.html Retrieves a list of all available color palettes, organized by series and type. Supports filtering by palette type and series. ```APIDOC ## GET /api/palettes ### Description Retrieves a list of all available color palettes from the cols4all package. Palettes can be filtered by type and series. ### Method GET ### Endpoint /api/palettes ### Query Parameters - **type** (string) - Optional - Type of color palette: 'all', 'cat', 'seq', 'div', 'cyc', 'bivs', 'bivc', 'bivd', or 'bivg'. Defaults to 'all'. - **series** (string) - Optional - Series to list the palettes from. See `c4a_series` for options. - **full.names** (boolean) - Optional - Whether to return full palette names including the series prefix. Defaults to TRUE. ### Response #### Success Response (200) - **palettes** (array of strings) - A list of palette names. #### Response Example ```json { "palettes": [ "viridis.viridis", "magma.magma", "inferno.inferno" ] } ``` ``` -------------------------------- ### Get Available Palette Types Source: https://cols4all.github.io/cols4all-R/reference/c4a_palettes.html Lists the different types of color palettes available, such as categorical, sequential, and diverging. Can return results as a data frame. ```APIDOC ## GET /api/types ### Description Lists the available types for color palettes within the cols4all package, including categorical, sequential, diverging, cyclic, and bivariate types. The output can be formatted as a data frame. ### Method GET ### Endpoint /api/types ### Query Parameters - **series** (string) - Optional - Filter types by a specific series. - **as.data.frame** (boolean) - Optional - Whether to return the result as a data frame with descriptions. Defaults to TRUE. ### Response #### Success Response (200) - **types** (array of objects or strings) - A list of palette type names or data frame rows describing each type. #### Response Example ```json { "types": [ { "name": "cat", "description": "Categorical palette" }, { "name": "seq", "description": "Sequential palette" } ] } ``` ``` -------------------------------- ### Get a cols4all color palette Source: https://cols4all.github.io/cols4all-R/reference/c4a.html Functions to retrieve colors from specified palettes, handle missing values, and create color ramp functions. ```APIDOC ## Get a cols4all color palette Source: `R/c4a.R` `c4a.Rd` `c4a` returns the colors of the specified palette, `c4a_na` returns the color for missing value that is associated with the specified palette, and `c4a_ramp` returns a color ramp function. Run `c4a_gui` to see all available palettes, which are also listed with `c4a_palettes`. ### Usage ```R c4a( palette = NULL, n = NA, m = NA, type = c("cat", "seq", "div", "cyc", "bivs", "bivc", "bivd", "bivg"), reverse = FALSE, diag_flip = FALSE, order = NULL, range = NA, colorsort = "orig", format = c("hex", "rgb", "hcl", "RGB", "XYZ", "HSV", "HLS", "LAB", "polarLAB", "LUV", "polarLUV"), nm_invalid = c("error", "repeat", "interpolate"), verbose = TRUE ) c4a_ramp(..., space = c("rgb", "Lab"), interpolate = c("linear", "spline")) c4a_na( palette = NULL, type = c("cat", "seq", "div", "cyc", "bivs", "bivc", "bivd", "bivg"), verbose = TRUE ) ``` ### Arguments `palette` name of the palette. See `c4a_palettes` for available palettes. If omitted, the default palette is provided by `c4a_default_palette`. The palette name can be prefixed with a `-` symbol, which will reverse the palette (this can also be done with the `reverse` argument). For bivariate palettes, a `-` means reversed horizontally (columns), a `|`means reversed vertically (row), and a `+` means reversed in both directions. In addition, a `//` or `\` will flip the palette diagonally. This can be used in combination with `-`, `|`, or `+`. E.g. `-//` will reverse the columns and flip the palette diagonally. `n` number of colors. If omitted then: for type `cat` the maximum number of colors is returned, for types `seq`, `div`, and `cyc`, 7 , 9, and 9 colors respectively. For bivariate palettes `n` is the number of columns. `m` number of rows in case type is bivariate, so one of `bivs`, `bivc`, `bivd` or `bivg` (see `c4a_types` for descriptions) `type` type of color palette, in case `palette` is not specified: one of `cat`, `seq`, `div`, `cyc`, `bivs`, `bivc`, `bivd`, `bivg`. Run `c4a_types` for descriptions. `reverse` should the palette be reversed? In case of a bivariate palette, a vector of two: the first indicates the horizontal direction (columns) and the second the vertical (rows). `diag_flip` should a bivariate palette be flipped diagonally? `order` order of colors. Only applicable for `cat` palettes `range` a vector of two numbers between 0 and 1 that determine the range that is used for sequential and diverging palettes. The first number determines where the palette begins, and the second number where it ends. For sequential `seq` palettes, 0 means the leftmost (normally lightest) color, and 1 the rightmost (often darkest) color. For diverging `seq` palettes, 0 means the middle color, and 1 both extremes. If only one number is provided, this number is interpreted as the endpoint (with 0 taken as the start). `colorsort` Sort the colors. Options: `orig` (original order), `Hx` (hue, where x is a starting number from 0 to 360), `C` (chroma), `L` (luminance). All these options are available for `cat` palettes, only the last one for `seq`, and none for the other palette types. `format` format of the colors. One of: `hex` character vector of hex color values, `rgb` 3 column matrix of RGB values, `hcl` 3-column matrix of HCL values, or one of the color classes from `colorspace` `nm_invalid` what should be done in case `n` or `m` is larger than the maximum number of colors or smaller than the minimum number? Options are `error` (an error is returned), `repeat` the palette is repeated, `interpolate` colors are interpolated. For categorical `cat` palettes only. `verbose` should messages be printed? `...` passed on to `c4a`. `space` a character string; interpolation in RGB or CIE Lab color spaces `interpolate` use spline or linear interpolation ### Value A vector of colors (`c4a`) and a color (`c4a_na`) ### Examples ```R # get the colors from brewer.set3 and plot them set3 <- c4a("brewer.set3") c4a_plot_hex(set3, nrows = 1) c4a("hcl.set2", n = 36) |> c4a_plot_hex() c4a("-hcl.set2", n = 12) |> c4a_plot_hex() # how to know which palettes are avaiable? # 1) Via the interactive tool: if (FALSE) { # \dontrun{ c4a_gui() } ``` ``` -------------------------------- ### Get and plot a specific number of colors Source: https://cols4all.github.io/cols4all-R/reference/c4a.html Retrieves 36 colors from the 'hcl.set2' palette and plots them. This demonstrates specifying the number of colors using the 'n' argument. ```R c4a("hcl.set2", n = 36) |> c4a_plot_hex() ``` -------------------------------- ### Cite palettes using c4a_citation Source: https://cols4all.github.io/cols4all-R/reference/c4a_citation.html Use this function to get citation details for color palettes. Set verbose to FALSE to return only a bibentry object. ```r c4a_citation("hcl") ``` ```r c4a_citation("poly.glasbey") ``` -------------------------------- ### Get and plot a reversed color palette Source: https://cols4all.github.io/cols4all-R/reference/c4a.html Retrieves 12 colors from the 'hcl.set2' palette in reverse order and plots them. The '-' prefix on the palette name reverses the color order. ```R c4a("-hcl.set2", n = 12) |> c4a_plot_hex() ``` -------------------------------- ### Get cols4all palette information Source: https://cols4all.github.io/cols4all-R/reference/c4a_info.html Use this function to retrieve details about a cols4all palette. Specify the palette name and control the behavior when no match is found. The function returns a list containing palette name, series, full name, type, colors, NA color, maximum number of colors, and a boolean indicating if the palette is reversed. ```R c4a_info(palette, no.match = c("message", "error", "null"), verbose = TRUE) ``` -------------------------------- ### Load and Import paletteer Palettes Source: https://cols4all.github.io/cols4all-R/articles/02_paletteer.html Load the prepared system data from 'paletteer' and import it into 'cols4all'. This replaces the default 'cols4all' palettes with those from 'paletteer'. ```r paletteer = readRDS(gzcon(url("https://cols4all.github.io/paletteer.rds"))) # from paletteer version 1.6.0 c4a_sysdata_import(paletteer) ``` -------------------------------- ### Import and Export cols4all System Data Source: https://cols4all.github.io/cols4all-R/reference/c4a_sysdata_import.html Demonstrates exporting current system data and then importing it back. Verifies that the exported and re-imported data are identical. ```R x = c4a_sysdata_export() c4a_sysdata_import(x) #> cols4all system data imported successfully y = c4a_sysdata_export() identical(x, y) #> [1] TRUE ``` -------------------------------- ### Explore available palettes interactively Source: https://cols4all.github.io/cols4all-R/reference/c4a.html Launches an interactive tool to view all available color palettes. This function is intended for interactive use and is wrapped in `if (FALSE)` to prevent execution during standard package checks. ```R if (FALSE) { # \dontrun{ c4a_gui() } # } ``` -------------------------------- ### Build palette data as is with c4a_data_as_is Source: https://cols4all.github.io/cols4all-R/reference/c4a_data.html Use `c4a_data_as_is` to build palette data without restructuring colors. It accepts arguments passed to `c4a_data` and defaults to not formatting palette names or removing grayscales. ```r c4a_data_as_is( ..., format.palette.name = FALSE, remove.blacks = FALSE, remove.whites = FALSE, take.gray.for.NA = FALSE, remove.other.grays = FALSE, light.to.dark = FALSE, remove.names = FALSE ) ``` -------------------------------- ### c4a_palettes() Source: https://cols4all.github.io/cols4all-R/reference/index.html Lists available palette names, series, and types within the package. ```APIDOC ## c4a_palettes() ### Description Get available palette names and series. ### Method Function Call ### Endpoint c4a_palettes() ``` -------------------------------- ### Configure color-blind friendliness thresholds Source: https://cols4all.github.io/cols4all-R/reference/c4a_options.html Adjusting thresholds for categorical palettes to change how color-blind friendliness is evaluated in the GUI. ```R if (FALSE) { # \dontrun{ c4a_table(n = 9, sort = "cbfriendly") opts = c4a_options("CBF_th", "CBVF_th") opts$CBF_th$cat["min_dist"] = 7 opts$CBVF_th$cat["min_dist"] = 10 old = c4a_options(opts) # more smileys :-) :-) c4a_table(n = 9, sort = "cbfriendly") # set the old settings back c4a_options(old) } # } ``` -------------------------------- ### List available palette types Source: https://cols4all.github.io/cols4all-R/reference/c4a_palettes.html Displays the different types of color palettes supported by the package. ```R c4a_types() ``` -------------------------------- ### Load cols4all Package Source: https://cols4all.github.io/cols4all-R/index.html Load the cols4all package into the R session to access its functions. ```R library(cols4all) ``` -------------------------------- ### Graphical User Interface for Palettes Source: https://cols4all.github.io/cols4all-R/reference/c4a_gui.html Launches a Shiny app for interactive analysis of color palettes. ```APIDOC ## c4a_gui() ### Description Launches a graphical user interface (Shiny app) for analyzing color palettes. ### Method Function call ### Endpoint N/A (R function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```R c4a_gui() ``` ### Response Launches a Shiny application in the user's default web browser. ``` -------------------------------- ### Access palettes via .P Source: https://cols4all.github.io/cols4all-R/reference/c4a.html Directly access palette objects using the .P shorthand. ```R .P$brewer$cat$set3 ``` -------------------------------- ### Sort sequential palettes by hue Source: https://cols4all.github.io/cols4all-R/reference/c4a_gui.html Displays sequential palettes with a specified number of colors, sorted by hue. Requires 'kableExtra'. ```R c4a_table(type = "seq", n = 7, sort = "H") ``` -------------------------------- ### Add Continuous Diverging Scale to ggplot2 Source: https://cols4all.github.io/cols4all-R/index.html Use `scale_color_continuous_c4a_div` to apply a cols4all continuous diverging color scale to a ggplot2 plot. The 'mid' argument should be set appropriately, for example, to the mean of the data. ```R # continuous diverging scale ggplot(diam_exp, aes(x = carat, y = depth, color = price)) + geom_point(size = 2) + scale_color_continuous_c4a_div("wes.zissou1", mid = mean(diam_exp$price)) + theme_light() ``` -------------------------------- ### Build and Load Palette Data Source: https://cols4all.github.io/cols4all-R/reference/c4a_data.html Functions to create, process, and register color palette data objects. ```APIDOC ## c4a_data ### Description Builds palette data from a named list of color palettes or a c4a_info object. This function allows for restructuring palette colors and defining metadata. ### Parameters #### Arguments - **x** (list/c4a_info) - Required - Named list of color palettes or a c4a_info object. - **xNA** (vector) - Optional - Colors for missing values. - **types** (character) - Optional - Type of palette: "cat", "seq", "div", "cyc", "bivs", "bivc", "bivd", or "bivg". - **series** (character) - Optional - Determines the series. - **nmin, nmax, ndef** (numeric) - Optional - Minimum, maximum, and default number of colors. - **mmin, mmax, mdef** (numeric) - Optional - Minimum, maximum, and default number of rows for bivariate palettes. - **format.palette.name** (boolean) - Optional - Whether to format names to lowercase/underscore. - **remove.blacks, remove.whites, take.gray.for.NA, remove.other.grays** (boolean) - Optional - Processing options for grayscale colors. - **light.to.dark** (boolean) - Optional - Whether to order sequential palettes from light to dark. - **remove.names** (boolean) - Optional - Whether to remove individual color names. - **biv.method** (string) - Optional - Method to create bivariate palettes. - **space** (string) - Optional - Color space for interpolation ("rgb" or "Lab"). - **range_matrix_args** (list) - Optional - Range specifications for sequential/diverging palettes. - **bib** (bibentry) - Optional - Bibtex reference. - **description** (string) - Optional - Description of the series. ### Response - **c4a_data object** (list) - Returns a list containing data, s, citation, and description. ## c4a_load ### Description Loads processed palette data into the cols4all environment. ### Parameters - **data** (c4a_data) - Required - Data created with c4a_data. - **overwrite** (boolean) - Optional - Whether to overwrite existing palettes. ## c4a_data_as_is ### Description Builds palette data without restructuring the palette colors. ### Parameters - **...** (dots) - Optional - Arguments passed to c4a_data. - **format.palette.name, remove.blacks, remove.whites, take.gray.for.NA, remove.other.grays, light.to.dark, remove.names** (boolean) - Optional - Processing flags. ``` -------------------------------- ### List available color palette series Source: https://cols4all.github.io/cols4all-R/reference/c4a_palettes.html Displays all available color palette series and their descriptions. ```R c4a_series() ``` -------------------------------- ### Define and apply custom nameability functions Source: https://cols4all.github.io/cols4all-R/reference/c4a_options.html Implementing a custom function to calculate color distance matrices and registering it via c4a_options. ```R naming_RGB = function(pal) { cols = colorspace::hex2RGB(pal) coords = cols@coords cls = apply(coords, MARGIN = 1, which.max) mx = apply(coords, MARGIN = 1, max) dominance = ((mx + 0.001) / (rowSums(coords) + 0.001)) cls[dominance < 0.4] = 4L m = matrix(0, nrow = length(pal), ncol = 4, dimnames = list(NULL, c("Red", "Green", "Blue", "Other"))) for (i in 1:nrow(m)) { m[i, cls[i]] = 1 } -m } # testing this function... naming_RGB(c4a("brewer.set1")) #fair enough #> Red Green Blue Other #> [1,] -1 0 0 0 #> [2,] 0 0 -1 0 #> [3,] 0 -1 0 0 #> [4,] 0 0 -1 0 #> [5,] -1 0 0 0 #> [6,] -1 0 0 0 #> [7,] -1 0 0 0 #> [8,] -1 0 0 0 #> [9,] 0 0 0 -1 # This vector should contain the 'prototype' colors, and have names that correspond # to the column names of the returned matrices by the function above. names_RGB = c("Red" = "#FF0000", "Green" = "#00FF00", "Blue" = "#0000FF", "Other" = "#AAAAAA") # Set the options (may take a while because if calculated the nameability scores) if (FALSE) { # \dontrun{ c4a_options(naming_fun = naming_RGB, naming_fun_args = list(), naming_colors = names_RGB) } # } ``` -------------------------------- ### Sort sequential palettes by number of hues Source: https://cols4all.github.io/cols4all-R/reference/c4a_gui.html Displays sequential palettes with a specified number of colors, sorted by the number of distinct hues used. Requires 'kableExtra'. ```R c4a_table(type = "seq", n = 5, sort = "hues") ``` -------------------------------- ### Display categorical palettes in a table Source: https://cols4all.github.io/cols4all-R/reference/c4a_gui.html Generates a table of categorical palettes. Requires the 'kableExtra' package for rendering. ```R c4a_table(type = "cat") ``` -------------------------------- ### Build palette data with c4a_data Source: https://cols4all.github.io/cols4all-R/reference/c4a_data.html Use `c4a_data` to build palette data, with options to restructure colors and handle missing values. It can also process `c4a_info` objects. ```r c4a_data( x, xNA = NA, types = "cat", series = "x", nmin = NA, nmax = NA, ndef = NA, mmin = NA, mmax = NA, mdef = NA, format.palette.name = TRUE, remove.blacks = NA, remove.whites = NA, take.gray.for.NA = FALSE, remove.other.grays = FALSE, light.to.dark = FALSE, remove.names = TRUE, biv.method = "byrow", space = "rgb", range_matrix_args = list(NULL), bib = NA, description = NA ) ``` -------------------------------- ### Show how to cite palettes Source: https://cols4all.github.io/cols4all-R/reference/c4a_citation.html This function allows users to retrieve citation information for color palettes or series within the cols4all package. ```APIDOC ## c4a_citation() ### Description Show how to cite palettes ### Method N/A (R function) ### Endpoint N/A (R function) ### Parameters #### Arguments - **name** (string) - Required - name of a palette or series - **verbose** (boolean) - Optional - should text be printed (if FALSE only a `utils::bibentry` object is returned) ### Request Example ```R c4a_citation("hcl") c4a_citation("poly.glasbey") ``` ### Response #### Success Response (200) - **bibentry** (`utils::bibentry`) - A citation object for the specified palette or series. #### Response Example ``` To cite palettes from series "hcl" in publications use: Zeileis A, Hornik K, Murrell P (2009). "Escaping RGBland: Selecting Colors for Statistical Graphics." _Computational Statistics & Data Analysis_, *53*(9), 3259-3270. doi:10.1016/j.csda.2008.11.033 . @Article{hcl, title = {Escaping {RGB}land: Selecting Colors for Statistical Graphics}, author = {Achim Zeileis and Kurt Hornik and Paul Murrell}, journal = {Computational Statistics & Data Analysis}, year = {2009}, volume = {53}, number = {9}, pages = {3259--3270}, doi = {10.1016/j.csda.2008.11.033}, } ``` ``` -------------------------------- ### List Available Color Palette Series Source: https://cols4all.github.io/cols4all-R/index.html Display a table of all available color palette series supported by the cols4all package, including their descriptions. ```R c4a_series() #> series description #> 1 brewer ColorBrewer palettes #> 2 carto Palettes designed by CARTO #> 3 cols4all cols4all palettes (in development) #> 4 gmt Palettes from General Mapping Tools #> 5 hcl Palettes from the Hue Chroma Luminance color space #> 6 kovesi Palettes designed by Peter Kovesi #> 7 matplotlib Palettes from the Python library matplotlib #> 8 met Palettes inspired by The Metropolitan Museum of Art #> 9 meteo Palettes by Oliver Fuhrer from MeteoSwiss #> 10 misc Miscellaneous palettes #> 11 ocean Colormaps for Oceanography by Thyng et al. #> 12 parks Palettes inspired by National Parks #> 13 poly Qualitative palettes with many colors #> 14 powerbi Palettes from Microsoft Power BI #> 15 scico Scientific colour maps by Fabio Crameri #> 16 seaborn Palettes from the Python library Seaborn #> 17 stevens Bivariate palettes by Joshua Stevens #> 18 tableau Palettes designed by Tableau #> 19 tol Palettes designed by Paul Tol #> 20 wes Palettes from Wes Anderson movies ``` -------------------------------- ### List palettes by series and type Source: https://cols4all.github.io/cols4all-R/reference/c4a.html Retrieve lists of available palettes using the c4a_palettes function with optional filters. ```R c4a_palettes(series = "brewer") ``` ```R c4a_palettes(type = "cat", series = "brewer") ``` -------------------------------- ### System Data Import and Export Source: https://cols4all.github.io/cols4all-R/reference/c4a_sysdata_import.html Functions to import, export, and remove system data for cols4all. ```APIDOC ## Import and export system data ### Description Import and export system data. `c4a_sysdata_import` will import system data and overwrite the current system data, `c4a_sysdata_export` will export the current system data, and `c4a_sysdata_remove` (partly) removes system data. ### Usage ```R c4a_sysdata_import(data) c4a_sysdata_export() c4a_sysdata_remove(fullnames = NULL, series = NULL, are.you.sure = NA) ``` ### Arguments #### `c4a_sysdata_import(data)` - **data** (cols4all data) - Description: cols4all data (see `c4a_data`) #### `c4a_sysdata_export()` - No arguments. #### `c4a_sysdata_remove(fullnames = NULL, series = NULL, are.you.sure = NA)` - **fullnames** (character vector) - Description: full palette names (so in the format `series.palette_name`) - **series** (character vector) - Description: a character vector of series names that should be removed (use `"all"` to remove all). - **are.you.sure** (logical) - Description: are you sure you want to remove series? ### Value `c4a_sysdata_export` returns the system data (a list) ### Examples ```R x = c4a_sysdata_export() c4a_sysdata_import(x) #> cols4all system data imported successfully y = c4a_sysdata_export() identical(x, y) #> [1] TRUE ``` ``` -------------------------------- ### Load palette data with c4a_load Source: https://cols4all.github.io/cols4all-R/reference/c4a_data.html Use `c4a_load` to load previously built cols4all data. The `overwrite` argument controls whether existing palettes with the same name will be replaced. ```r c4a_load(data, overwrite = FALSE) ``` -------------------------------- ### Create and visualize color ramps Source: https://cols4all.github.io/cols4all-R/reference/c4a.html Generate color ramps and visualize them using the c4a_plot function. ```R c4a("viridis", 100) |> c4a_plot() ``` ```R c4a_ramp("viridis")(100) |> c4a_plot() ``` -------------------------------- ### Define and Load Pink Floyd Palettes Source: https://cols4all.github.io/cols4all-R/reference/c4a_data.html Defines a named list of hex color vectors and registers them as a new series in the cols4all package. ```R pf = list(piper = c("#391C1C", "#C6C6AA", "#713939", "#C6391C", "#C6E3C6", "#AA7155", "#AA8E71", "#C68E71"), saucerful = c("#000000", "#1C1C1C", "#393939", "#FFFFFF", "#555555", "#8E8E71", "#E3C6AA", "#715539"), atom = c("#C6E3FF", "#397139", "#557139", "#E3E3C6", "#1C1C1C", "#1C551C", "#AAAA8E", "#8EC6E3"), meddle = c("#715539", "#553939", "#8E7155", "#71AAAA", "#8E8E71", "#1CAAE3", "#55C6E3", "#AA7155"), obscured = c("#000000", "#1C1C1C", "#393939", "#717155", "#8E8E71", "#715539", "#C6AA8E", "#E3C6AA"), moon = c("#000000", "#FF0000", "#FF9224", "#FFFF00", "#71C600", "#00C6FF", "#8E398E", "#FFFFFF"), wish = c("#FFFFFF", "#AAC6E3", "#8E8E8E", "#717155", "#555539", "#8E8E71", "#555555", "#8E7155"), animals = c("#391C39", "#393955", "#E3C671", "#718E8E", "#AAAA8E", "#C67139", "#AA5539", "#E3AA39"), wall = c("#FFFFFF", "#E3E3E3", "#C6C6C6", "#AAAAC6", "#1C1C1C", "#000000", "#8E8E8E", "#E3C6E3"), cut = c("#000000", "#E30000", "#AA0000", "#391C55", "#FFE3E3", "#1C1C00", "#FFAA55", "#8E8E55"), lapse = c("#000000", "#8E8EC6", "#8E8E71", "#7171AA", "#39391C", "#717171", "#AAAAAA", "#E3E3E3"), division = c("#000000", "#FFFFC6", "#00398E", "#AA8E55", "#39558E", "#C6AA71", "#39391C", "#555571"), more = c("#0055AA", "#FFAA1C", "#1C71AA", "#003971", "#E38E55", "#E3AAAA", "#718EAA", "#71718E"), umma = c("#AA8E71", "#555539", "#39391C", "#1C1C1C", "#E3E3C6", "#715539", "#391C1C", "#8E7155"), relics = c("#3955AA", "#1C3971", "#5571C6", "#715555", "#8E7155", "#E3AA71", "#8E8EAA", "#E3FFFF"), river = c("#393939", "#555555", "#39558E", "#C6C6C6", "#718EAA", "#1C1C1C", "#717171", "#E3C68E")) if (requireNamespace("colorblindcheck", quietly = TRUE)) { pfdata = c4a_data_as_is(pf, series = "pinkfloyd", description = "Palettes extracted from Pink Floyd album covers") c4a_load(pfdata) c4a_series() c4a_overview() if (requireNamespace("shiny") && requireNamespace("shinyjs") && requireNamespace("kableExtra") && requireNamespace("colorblindcheck") && requireNamespace("plotly") && interactive()) { c4a_gui(series = "pinkfloyd", n = 8) } } ``` -------------------------------- ### c4a_info() Source: https://cols4all.github.io/cols4all-R/reference/index.html Retrieves metadata and information about a specific cols4all palette. ```APIDOC ## c4a_info() ### Description Get information from a cols4all palette. ### Method Function Call ### Endpoint c4a_info() ```