### Install viridisLite from CRAN Source: https://github.com/sjmgarnier/viridislite/blob/master/README.md Install the viridisLite package from CRAN and load it into the R session. This is the standard way to install packages for general use. ```r install.packages("viridisLite") library(viridisLite) ``` -------------------------------- ### HotellingEllipse Package Installation Error (Devel) Source: https://github.com/sjmgarnier/viridislite/blob/master/revdep/failures.md This snippet shows the error encountered when installing the 'HotellingEllipse' package from its development version. The installation fails during the byte-compilation and lazy loading phase due to a missing dependency: the 'emmeans' package. This indicates that 'emmeans' must be installed before 'HotellingEllipse'. ```bash * installing *source* package ‘HotellingEllipse’ ... ** this is package ‘HotellingEllipse’ version ‘1.2.0’ ** package ‘HotellingEllipse’ successfully unpacked and MD5 sums checked ** using staged installation ** R ** data *** moving datasets to lazyload DB ** inst ** byte-compile and prepare package for lazy loading Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called ‘emmeans’ Calls: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart Execution halted ERROR: lazy loading failed for package ‘HotellingEllipse’ * removing ‘/Users/simon/Library/CloudStorage/Box-Box/Swarm Lab/Software/R/viridisLite/revdep/checks.noindex/HotellingEllipse/new/HotellingEllipse.Rcheck/HotellingEllipse’ ``` -------------------------------- ### HotellingEllipse Package Installation Error (CRAN) Source: https://github.com/sjmgarnier/viridislite/blob/master/revdep/failures.md This snippet illustrates the installation failure of the 'HotellingEllipse' package from CRAN. The error occurs during the lazy loading step, reporting that the 'emmeans' package is not found. This signifies a missing dependency that needs to be resolved by installing 'emmeans' prior to installing 'HotellingEllipse'. ```bash * installing *source* package ‘HotellingEllipse’ ... ** this is package ‘HotellingEllipse’ version ‘1.2.0’ ** package ‘HotellingEllipse’ successfully unpacked and MD5 sums checked ** using staged installation ** R ** data *** moving datasets to lazyload DB ** inst ** byte-compile and prepare package for lazy loading Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called ‘emmeans’ Calls: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart Execution halted ERROR: lazy loading failed for package ‘HotellingEllipse’ * removing ‘/Users/simon/Library/CloudStorage/Box-Box/Swarm Lab/Software/R/viridisLite/revdep/checks.noindex/HotellingEllipse/old/HotellingEllipse.Rcheck/HotellingEllipse’ ``` -------------------------------- ### Install viridisLite Development Version from GitHub Source: https://github.com/sjmgarnier/viridislite/blob/master/README.md Install the development version of viridisLite directly from its GitHub repository using the devtools package. This is useful for accessing the latest features or bug fixes. ```r if (!require("devtools")) install.packages("devtools") devtools::install_github("sjmgarnier/viridisLite") library(viridisLite) ``` -------------------------------- ### Install and Load viridisLite Package Source: https://context7.com/sjmgarnier/viridislite/llms.txt Installs the viridisLite package from CRAN or GitHub and loads it into the R session. Use the CRAN version for stable releases and the GitHub version for the latest development features. ```r # From CRAN (stable) install.packages("viridisLite") library(viridisLite) # Development version from GitHub if (!require("devtools")) install.packages("devtools") devtools::install_github("sjmgarnier/viridisLite") library(viridisLite) ``` -------------------------------- ### Quartet Package Installation Failure Source: https://github.com/sjmgarnier/viridislite/blob/master/revdep/failures.md Indicates a general installation failure for the Quartet package. Refer to the specified log file for detailed error messages. ```text Installation failed. See ‘/Users/simon/Library/CloudStorage/Box-Box/Swarm Lab/Software/R/viridisLite/revdep/checks.noindex/Quartet/new/Quartet.Rcheck/00install.out’ for details. ``` -------------------------------- ### eaf Package Installation Error (Devel) Source: https://github.com/sjmgarnier/viridislite/blob/master/revdep/failures.md This snippet shows the error message during the development installation of the 'eaf' package. The failure is due to the 'gsl-config' utility not being found, which is required for the package's configuration. It suggests installing system libraries like 'libgsl-dev' and checking the PATH for 'pkg-config'. ```bash * installing *source* package ‘eaf’ ... ** this is package ‘eaf’ version ‘2.5.2’ ** package ‘eaf’ successfully unpacked and MD5 sums checked ** using staged installation checking for gsl-config... no configure: error: --------------------------- EAF PACKAGE -------------------------------- Configuration failed because gsl-config was not found. Try installing: * Debian, Ubuntu, etc: sudo apt-get install libgsl-dev * Fedora, CentOS, RHEL: sudo yum install libgsl-dev ... If gsl-config is already installed, check that 'pkg-config' is in your PATH and PKG_CONFIG_PATH contains a gsl-config.pc file. If pkg-config is unavailable you can set INCLUDE_DIR and LIB_DIR manually via: R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...' -------------------------- ERROR MESSAGE --------------------------- cat configure.log -------------------------------------------------------------------- ERROR: configuration failed for package ‘eaf’ * removing ‘/Users/simon/Library/CloudStorage/Box-Box/Swarm Lab/Software/R/viridisLite/revdep/checks.noindex/eaf/new/eaf.Rcheck/eaf’ ``` -------------------------------- ### eaf Package Installation Error (CRAN) Source: https://github.com/sjmgarnier/viridislite/blob/master/revdep/failures.md This snippet details the installation error for the 'eaf' package from CRAN. Similar to the devel version, the installation fails because 'gsl-config' is not found, indicating a missing system dependency. The error message provides instructions for installing the necessary libraries on Debian/Ubuntu and Fedora/CentOS systems. ```bash * installing *source* package ‘eaf’ ... ** this is package ‘eaf’ version ‘2.5.2’ ** package ‘eaf’ successfully unpacked and MD5 sums checked ** using staged installation checking for gsl-config... no configure: error: --------------------------- EAF PACKAGE -------------------------------- Configuration failed because gsl-config was not found. Try installing: * Debian, Ubuntu, etc: sudo apt-get install libgsl-dev * Fedora, CentOS, RHEL: sudo yum install libgsl-dev ... If gsl-config is already installed, check that 'pkg-config' is in your PATH and PKG_CONFIG_PATH contains a gsl-config.pc file. If pkg-config is unavailable you can set INCLUDE_DIR and LIB_DIR manually via: R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...' -------------------------- ERROR MESSAGE --------------------------- cat configure.log -------------------------------------------------------------------- ERROR: configuration failed for package ‘eaf’ * removing ‘/Users/simon/Library/CloudStorage/Box-Box/Swarm Lab/Software/R/viridisLite/revdep/checks.noindex/eaf/old/eaf.Rcheck/eaf’ ``` -------------------------------- ### Quartet Package Devel Installation Error: Missing RcppHungarian Source: https://github.com/sjmgarnier/viridislite/blob/master/revdep/failures.md Shows the build process for the Quartet package (devel version) failing due to a missing dependency on the 'RcppHungarian' package during the byte-compilation phase. This error halts the installation. ```text * installing *source* package ‘Quartet’ ... ** this is package ‘Quartet’ version ‘1.2.7’ ** package ‘Quartet’ successfully unpacked and MD5 sums checked ** using staged installation ** libs using C++ compiler: ‘Apple clang version 17.0.0 (clang-1700.6.3.2)’ using SDK: ‘MacOSX26.2.sdk’ clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/include" -DNDEBUG -I'/Users/simon/Library/CloudStorage/Box-Box/Swarm Lab/Software/R/viridisLite/revdep/library.noindex/Quartet/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c AbstractDistanceCalculator.cpp -o AbstractDistanceCalculator.o clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/include" -DNDEBUG -I'/Users/simon/Library/CloudStorage/Box-Box/Swarm Lab/Software/R/viridisLite/revdep/library.noindex/Quartet/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c AllQuartets.cpp -o AllQuartets.o clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/include" -DNDEBUG -I'/Users/simon/Library/CloudStorage/Box-Box/Swarm Lab/Software/R/viridisLite/revdep/library.noindex/Quartet/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c EdgeParser.cpp -o EdgeParser.o ... ** data *** moving datasets to lazyload DB ** inst ** byte-compile and prepare package for lazy loading Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called ‘RcppHungarian’ Calls: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart Execution halted ERROR: lazy loading failed for package ‘Quartet’ * removing ‘/Users/simon/Library/CloudStorage/Box-Box/Swarm Lab/Software/R/viridisLite/revdep/checks.noindex/Quartet/new/Quartet.Rcheck/Quartet’ ``` -------------------------------- ### Quartet Package CRAN Installation Error: Missing RcppHungarian Source: https://github.com/sjmgarnier/viridislite/blob/master/revdep/failures.md Details the installation failure of the Quartet package from CRAN, specifically highlighting the 'RcppHungarian' dependency missing during the byte-compilation step. This prevents the package from being installed. ```text * installing *source* package ‘Quartet’ ... ** this is package ‘Quartet’ version ‘1.2.7’ ** package ‘Quartet’ successfully unpacked and MD5 sums checked ** using staged installation ** libs using C++ compiler: ‘Apple clang version 17.0.0 (clang-1700.6.3.2)’ using SDK: ‘MacOSX26.2.sdk’ clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/include" -DNDEBUG -I'/Users/simon/Library/CloudStorage/Box-Box/Swarm Lab/Software/R/viridisLite/revdep/library.noindex/Quartet/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c AbstractDistanceCalculator.cpp -o AbstractDistanceCalculator.o clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/include" -DNDEBUG -I'/Users/simon/Library/CloudStorage/Box-Box/Swarm Lab/Software/R/viridisLite/revdep/library.noindex/Quartet/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c AllQuartets.cpp -o AllQuartets.o clang++ -arch arm64 -std=gnu++17 -I"/Library/Frameworks/R.framework/Versions/4.5-arm64/Resources/include" -DNDEBUG -I'/Users/simon/Library/CloudStorage/Box-Box/Swarm Lab/Software/R/viridisLite/revdep/library.noindex/Quartet/Rcpp/include' -I/opt/R/arm64/include -fPIC -falign-functions=64 -Wall -g -O2 -c EdgeParser.cpp -o EdgeParser.o ... ** data *** moving datasets to lazyload DB ** inst ** byte-compile and prepare package for lazy loading Error in loadNamespace(j <- i[[1L]], c(lib.loc, .libPaths()), versionCheck = vI[[j]]) : there is no package called ‘RcppHungarian’ Calls: ... loadNamespace -> withRestarts -> withOneRestart -> doWithOneRestart Execution halted ERROR: lazy loading failed for package ‘Quartet’ * removing ‘/Users/simon/Library/CloudStorage/Box-Box/Swarm Lab/Software/R/viridisLite/revdep/checks.noindex/Quartet/old/Quartet.Rcheck/Quartet’ ``` -------------------------------- ### viridisMap() — Get raw RGBA channel data frame Source: https://context7.com/sjmgarnier/viridislite/llms.txt Returns a data frame with columns R, G, B, and alpha (all in [0, 1]) for n equally spaced colors along the selected map. Useful when downstream code needs numeric channel values rather than hex strings. ```APIDOC ## viridisMap() ### Description Returns a data frame with columns `R`, `G`, `B`, and `alpha` (all in [0, 1]) for `n` equally spaced colors along the selected map. Useful when downstream code needs numeric channel values rather than hex strings — e.g., for export, custom rendering, or passing into non-R tools. ### Parameters #### Path Parameters None #### Query Parameters - **n** (integer) - The number of colors to generate. - **alpha** (numeric) - Alpha transparency value (0 to 1). - **begin** (numeric) - The sub-range of the palette to sample (0 to 1). - **end** (numeric) - The sub-range of the palette to sample (0 to 1). - **direction** (integer) - The direction of the gradient (-1 for dark-to-light, 1 for light-to-dark). - **option** (character) - The color map option to use (e.g., "viridis", "magma", "plasma"). ### Request Example ```r library(viridisLite) # Default: 256 rows of the viridis map vm <- viridisMap(256) # Mako map, 10 colors, restricted range, with alpha mk_map <- viridisMap(10, alpha = 0.5, begin = 0.1, end = 0.9, option = "mako") # Convert to matrix for use in raster operations color_matrix <- as.matrix(viridisMap(512, option = "turbo")[, c("R", "G", "B")]) # Export to CSV for use in other tools write.csv(viridisMap(256, option = "plasma"), "plasma_colormap.csv", row.names = FALSE) ``` ### Response #### Success Response (200) - **rgba_dataframe** (data.frame) - A data frame with columns R, G, B, and alpha. ``` -------------------------------- ### Get Raw RGBA Data with viridisMap() Source: https://context7.com/sjmgarnier/viridislite/llms.txt Retrieves raw RGBA channel data for a specified number of colors from a chosen map. This is useful for exporting color data or integrating with tools that require numeric color channel values. ```r library(viridisLite) # Default: 256 rows of the viridis map vm <- viridisMap(256) head(vm, 3) # R G B alpha # 1 0.2670010 0.0048740 0.3294118 1 # 2 0.2692990 0.0096670 0.3350980 1 # 3 0.2715310 0.0146430 0.3407843 1 # Mako map, 10 colors, restricted range, with alpha mk_map <- viridisMap(10, alpha = 0.5, begin = 0.1, end = 0.9, option = "mako") print(mk_map) # Convert to matrix for use in raster operations color_matrix <- as.matrix(viridisMap(512, option = "turbo")[, c("R", "G", "B")]) # Export to CSV for use in other tools (e.g., Python, JavaScript) write.csv(viridisMap(256, option = "plasma"), "plasma_colormap.csv", row.names = FALSE) ``` -------------------------------- ### magma() — Convenience wrapper for the magma color map Source: https://context7.com/sjmgarnier/viridislite/llms.txt A shorthand for viridis(..., option = "magma"). All other parameters (alpha, begin, end, direction) behave identically to viridis(). ```APIDOC ## magma() ### Description A shorthand for `viridis(..., option = "magma")`. All other parameters (`alpha`, `begin`, `end`, `direction`) behave identically to `viridis()`. ### Parameters #### Path Parameters None #### Query Parameters - **n** (integer) - The number of colors to generate. - **alpha** (numeric) - Alpha transparency value (0 to 1). - **begin** (numeric) - The sub-range of the palette to sample (0 to 1). - **end** (numeric) - The sub-range of the palette to sample (0 to 1). - **direction** (integer) - The direction of the gradient (-1 for dark-to-light, 1 for light-to-dark). ### Request Example ```r library(viridisLite) # 8 magma hex colors magma(8) # Reversed magma with transparency magma(12, alpha = 0.7, direction = -1) ``` ### Response #### Success Response (200) - **hex_color_vector** (character) - A character vector of hex color codes. ``` -------------------------------- ### plasma() Source: https://context7.com/sjmgarnier/viridislite/llms.txt Convenience wrapper for the plasma color map. A shorthand for viridis(..., option = "plasma"). ```APIDOC ## plasma() ### Description Convenience wrapper for the plasma color map. A shorthand for `viridis(..., option = "plasma")`. ### Usage ```r plasma(n, alpha = 1, begin = 0, end = 1, option = "plasma") ``` ### Arguments * `n`: Number of colors. * `alpha`: Transparency level. * `begin`: The normalized level of the smallest color to use. * `end`: The normalized level of the largest color to use. * `option`: The color map option to use (e.g., "plasma"). ### Examples ```r library(viridisLite) # 256-color plasma gradient for smooth color ramps cols <- plasma(256) # Use in contour/filled-contour plots x <- y <- seq(-3, 3, length.out = 50) z <- outer(x, y, function(a, b) sin(a) * cos(b)) filled.contour(x, y, z, color.palette = function(n) plasma(n), main = "Filled contour with plasma") ``` ``` -------------------------------- ### Display Viridis Palette with R Base Graphics Source: https://github.com/sjmgarnier/viridislite/blob/master/docs/reference/viridis.html Demonstrates how to display a viridis color palette using R's base image function. Useful for visualizing the color scale. ```r # using code from RColorBrewer to demo the palette n = 200 image( 1:n, 1, as.matrix(1:n), col = viridis(n, option = "D"), xlab = "viridis n", ylab = "", xaxt = "n", yaxt = "n", bty = "n" ) ``` -------------------------------- ### inferno() Source: https://context7.com/sjmgarnier/viridislite/llms.txt Convenience wrapper for the inferno color map. A shorthand for viridis(..., option = "inferno"). ```APIDOC ## inferno() ### Description Convenience wrapper for the inferno color map. A shorthand for `viridis(..., option = "inferno")`. ### Usage ```r inferno(n, alpha = 1, begin = 0, end = 1, option = "inferno") ``` ### Arguments * `n`: Number of colors. * `alpha`: Transparency level. * `begin`: The normalized level of the smallest color to use. * `end`: The normalized level of the largest color to use. * `option`: The color map option to use (e.g., "inferno"). ### Examples ```r library(viridisLite) # Heatmap using inferno m <- matrix(rnorm(400), 20, 20) image(m, col = inferno(64), main = "Heatmap with inferno") # Subset of the map to avoid near-black and near-white extremes safe_inferno <- inferno(32, begin = 0.1, end = 0.85) ``` ``` -------------------------------- ### Generate Magma Color Map with magma() Source: https://context7.com/sjmgarnier/viridislite/llms.txt A convenience wrapper for `viridis(..., option = "magma")`. Generates hex color codes for the magma color map, supporting parameters like alpha, begin, end, and direction. ```r library(viridisLite) # 8 magma hex colors magma(8) # Reversed magma with transparency magma(12, alpha = 0.7, direction = -1) # Pass as a function name where a palette function is expected (e.g., viridis package) ``` -------------------------------- ### turbo() Source: https://context7.com/sjmgarnier/viridislite/llms.txt Convenience wrapper for the turbo color map. A shorthand for viridis(..., option = "turbo"). Turbo is an improved rainbow-style map designed to reduce false detail and banding while maintaining colorblind-friendliness. ```APIDOC ## turbo() ### Description Convenience wrapper for the turbo color map. A shorthand for `viridis(..., option = "turbo")`. Turbo is an improved rainbow-style map designed to reduce false detail and banding while maintaining colorblind-friendliness. ### Usage ```r turbo(n, alpha = 1, begin = 0, end = 1, option = "turbo") ``` ### Arguments * `n`: Number of colors. * `alpha`: Transparency level. * `begin`: The normalized level of the smallest color to use. * `end`: The normalized level of the largest color to use. * `option`: The color map option to use (e.g., "turbo"). ### Examples ```r library(viridisLite) # Turbo for depth/elevation data where rainbow-like appearance is needed turbo(10) # Full-range gradient depth_cols <- turbo(256) image(matrix(1:256, nrow = 1), col = depth_cols, xaxt = "n", yaxt = "n", main = "turbo gradient") ``` ``` -------------------------------- ### rocket() Source: https://context7.com/sjmgarnier/viridislite/llms.txt Convenience wrapper for the rocket color map. A shorthand for viridis(..., option = "rocket"). Originally from the Seaborn Python package. ```APIDOC ## rocket() ### Description Convenience wrapper for the rocket color map. A shorthand for `viridis(..., option = "rocket")`. Originally from the Seaborn Python package. ### Usage ```r rocket(n, alpha = 1, begin = 0, end = 1, option = "rocket") ``` ### Arguments * `n`: Number of colors. * `alpha`: Transparency level. * `begin`: The normalized level of the smallest color to use. * `end`: The normalized level of the largest color to use. * `option`: The color map option to use (e.g., "rocket"). ### Examples ```r library(viridisLite) # Rocket palette for density/intensity maps ocket(6) # Use reversed for bright-to-dark encoding ocket(50, direction = -1) ``` ``` -------------------------------- ### mako() Source: https://context7.com/sjmgarnier/viridislite/llms.txt Convenience wrapper for the mako color map. A shorthand for viridis(..., option = "mako"). Originally from the Seaborn Python package; a cool blue-green palette. ```APIDOC ## mako() ### Description Convenience wrapper for the mako color map. A shorthand for `viridis(..., option = "mako")`. Originally from the Seaborn Python package; a cool blue-green palette. ### Usage ```r mako(n, alpha = 1, begin = 0, end = 1, option = "mako") ``` ### Arguments * `n`: Number of colors. * `alpha`: Transparency level. * `begin`: The normalized level of the smallest color to use. * `end`: The normalized level of the largest color to use. * `option`: The color map option to use (e.g., "mako"). ### Examples ```r library(viridisLite) mako(5) # [1] "#0B0405FF" "#382A54FF" "#395D9CFF" "#29AF7FFF" "#DEF5E5FF" # Use for ocean/environmental data visualizations n <- 200 image(matrix(seq(0, 1, length.out = n), nrow = 1), col = mako(n), xaxt = "n", yaxt = "n", main = "mako color strip") ``` ``` -------------------------------- ### cividis Source: https://github.com/sjmgarnier/viridislite/blob/master/docs/reference/viridis.html Convenience function for the 'cividis' color map. ```APIDOC ## cividis ### Description Convenience function for the 'cividis' color map option. Useful when the scale must be passed as a function name. ### Usage ```R cividis(n, alpha = 1, begin = 0, end = 1, direction = 1) ``` ### Arguments * **n** (integer) - The number of colors (\(\ge 1\)) to be in the palette. * **alpha** (numeric) - The alpha transparency, a number in \([0,1]\). * **begin** (numeric) - The (corrected) hue in \([0,1]\) at which the color map begins. * **end** (numeric) - The (corrected) hue in \([0,1]\) at which the color map ends. * **direction** (numeric) - Sets the order of colors in the scale. If 1 (default), colors are ordered from darkest to lightest. If -1, the order of colors is reversed. ### Value Returns a character vector of color hex codes. ``` -------------------------------- ### plasma Source: https://github.com/sjmgarnier/viridislite/blob/master/docs/reference/viridis.html Convenience function for the 'plasma' color map. ```APIDOC ## plasma ### Description Convenience function for the 'plasma' color map option. Useful when the scale must be passed as a function name. ### Usage ```R plasma(n, alpha = 1, begin = 0, end = 1, direction = 1) ``` ### Arguments * **n** (integer) - The number of colors (\(\ge 1\)) to be in the palette. * **alpha** (numeric) - The alpha transparency, a number in \([0,1]\). * **begin** (numeric) - The (corrected) hue in \([0,1]\) at which the color map begins. * **end** (numeric) - The (corrected) hue in \([0,1]\) at which the color map ends. * **direction** (numeric) - Sets the order of colors in the scale. If 1 (default), colors are ordered from darkest to lightest. If -1, the order of colors is reversed. ### Value Returns a character vector of color hex codes. ``` -------------------------------- ### magma Source: https://github.com/sjmgarnier/viridislite/blob/master/docs/reference/viridis.html Convenience function for the 'magma' color map. ```APIDOC ## magma ### Description Convenience function for the 'magma' color map option. Useful when the scale must be passed as a function name. ### Usage ```R magma(n, alpha = 1, begin = 0, end = 1, direction = 1) ``` ### Arguments * **n** (integer) - The number of colors (\(\ge 1\)) to be in the palette. * **alpha** (numeric) - The alpha transparency, a number in \([0,1]\). * **begin** (numeric) - The (corrected) hue in \([0,1]\) at which the color map begins. * **end** (numeric) - The (corrected) hue in \([0,1]\) at which the color map ends. * **direction** (numeric) - Sets the order of colors in the scale. If 1 (default), colors are ordered from darkest to lightest. If -1, the order of colors is reversed. ### Value Returns a character vector of color hex codes. ``` -------------------------------- ### cividis() Source: https://context7.com/sjmgarnier/viridislite/llms.txt Convenience wrapper for the cividis color map. A shorthand for viridis(..., option = "cividis"). Cividis is a corrected viridis variant optimized to be perceivable across all forms of color blindness. ```APIDOC ## cividis() ### Description Convenience wrapper for the cividis color map. A shorthand for `viridis(..., option = "cividis")`. Cividis is a corrected viridis variant optimized to be perceivable across all forms of color blindness. ### Usage ```r cividis(n, alpha = 1, begin = 0, end = 1, option = "cividis") ``` ### Arguments * `n`: Number of colors. * `alpha`: Transparency level. * `begin`: The normalized level of the smallest color to use. * `end`: The normalized level of the largest color to use. * `option`: The color map option to use (e.g., "cividis"). ### Examples ```r library(viridisLite) # 10 cividis colors cividis(10) # [1] "#00204DFF" "#00336FFF" "#39486BFF" "#575C6DFF" "#707173FF" # [6] "#8A8779FF" "#A69D75FF" "#C4B56CFF" "#E4CF5BFF" "#FFEA46FF" # Useful for accessibility-critical publications barplot(1:7, col = cividis(7), main = "Cividis - maximally accessible") ``` ``` -------------------------------- ### turbo Source: https://github.com/sjmgarnier/viridislite/blob/master/docs/reference/viridis.html Convenience function for the 'turbo' color map. ```APIDOC ## turbo ### Description Convenience function for the 'turbo' color map option. Useful when the scale must be passed as a function name. ### Usage ```R turbo(n, alpha = 1, begin = 0, end = 1, direction = 1) ``` ### Arguments * **n** (integer) - The number of colors (\(\ge 1\)) to be in the palette. * **alpha** (numeric) - The alpha transparency, a number in \([0,1]\). * **begin** (numeric) - The (corrected) hue in \([0,1]\) at which the color map begins. * **end** (numeric) - The (corrected) hue in \([0,1]\) at which the color map ends. * **direction** (numeric) - Sets the order of colors in the scale. If 1 (default), colors are ordered from darkest to lightest. If -1, the order of colors is reversed. ### Value Returns a character vector of color hex codes. ``` -------------------------------- ### Generate Hex Color Palette with viridis() Source: https://context7.com/sjmgarnier/viridislite/llms.txt Generates a vector of hex color codes from a specified color map. Customize the number of colors, alpha transparency, sub-range of the palette, and direction. Useful for direct use in R graphics. ```r library(viridisLite) # Basic usage: 5 colors from the default viridis (D) map viridis(5) # [1] "#440154FF" "#3B528BFF" "#21908CFF" "#5DC963FF" "#FDE725FF" # Plasma palette with 10 colors and 80% opacity plasma_cols <- viridis(10, alpha = 0.8, option = "plasma") print(plasma_cols) # [1] "#0D0887CC" "#47039FCC" "#7301A8CC" "#9C179ECC" "#BD3786CC" # [6] "#D8576BCC" "#ED7953CC" "#FA9E3BCC" "#FDC926CC" "#F0F921CC" # Sample only the middle portion of the magma map (avoid very dark/light ends) mid_magma <- viridis(8, begin = 0.2, end = 0.8, option = "magma") # Reversed direction (light to dark instead of dark to light) rev_inferno <- viridis(6, direction = -1, option = "inferno") # Use in base R graphics n <- 100 image( matrix(1:n, nrow = 10), col = viridis(n, option = "viridis"), main = "viridis palette" ) # Use with a scatter plot colored by a continuous variable x <- rnorm(200) y <- rnorm(200) z <- x^2 + y^2 # continuous value to encode as color color_indices <- cut(z, breaks = 50, labels = FALSE) plot(x, y, col = viridis(50)[color_indices], pch = 19, main = "Scatter plot with viridis coloring") ``` -------------------------------- ### inferno Source: https://github.com/sjmgarnier/viridislite/blob/master/docs/reference/viridis.html Convenience function for the 'inferno' color map. ```APIDOC ## inferno ### Description Convenience function for the 'inferno' color map option. Useful when the scale must be passed as a function name. ### Usage ```R inferno(n, alpha = 1, begin = 0, end = 1, direction = 1) ``` ### Arguments * **n** (integer) - The number of colors (\(\ge 1\)) to be in the palette. * **alpha** (numeric) - The alpha transparency, a number in \([0,1]\). * **begin** (numeric) - The (corrected) hue in \([0,1]\) at which the color map begins. * **end** (numeric) - The (corrected) hue in \([0,1]\) at which the color map ends. * **direction** (numeric) - Sets the order of colors in the scale. If 1 (default), colors are ordered from darkest to lightest. If -1, the order of colors is reversed. ### Value Returns a character vector of color hex codes. ``` -------------------------------- ### Color Palette Functions Source: https://github.com/sjmgarnier/viridislite/blob/master/docs/reference/index.html These functions generate various color palettes. Each function returns a vector of hexadecimal color codes. ```APIDOC ## viridis() ### Description Generates the viridis color palette. ### Usage viridis(n, alpha = 1, begin = 0, end = 1, option = "viridis") ### Arguments * `n` - Number of colors to generate. * `alpha` - Transparency level. * `begin` - The starting point of the color scale. * `end` - The ending point of the color scale. * `option` - The color palette option to use (e.g., "viridis", "magma", "inferno", "plasma", "cividis", "rocket", "mako", "turbo"). ## magma() ### Description Generates the magma color palette. ### Usage magma(n, alpha = 1, begin = 0, end = 1, option = "magma") ### Arguments * `n` - Number of colors to generate. * `alpha` - Transparency level. * `begin` - The starting point of the color scale. * `end` - The ending point of the color scale. * `option` - The color palette option to use. ## inferno() ### Description Generates the inferno color palette. ### Usage inferno(n, alpha = 1, begin = 0, end = 1, option = "inferno") ### Arguments * `n` - Number of colors to generate. * `alpha` - Transparency level. * `begin` - The starting point of the color scale. * `end` - The ending point of the color scale. * `option` - The color palette option to use. ## plasma() ### Description Generates the plasma color palette. ### Usage plasma(n, alpha = 1, begin = 0, end = 1, option = "plasma") ### Arguments * `n` - Number of colors to generate. * `alpha` - Transparency level. * `begin` - The starting point of the color scale. * `end` - The ending point of the color scale. * `option` - The color palette option to use. ## cividis() ### Description Generates the cividis color palette. ### Usage cividis(n, alpha = 1, begin = 0, end = 1, option = "cividis") ### Arguments * `n` - Number of colors to generate. * `alpha` - Transparency level. * `begin` - The starting point of the color scale. * `end` - The ending point of the color scale. * `option` - The color palette option to use. ## rocket() ### Description Generates the rocket color palette. ### Usage rocket(n, alpha = 1, begin = 0, end = 1, option = "rocket") ### Arguments * `n` - Number of colors to generate. * `alpha` - Transparency level. * `begin` - The starting point of the color scale. * `end` - The ending point of the color scale. * `option` - The color palette option to use. ## mako() ### Description Generates the mako color palette. ### Usage mako(n, alpha = 1, begin = 0, end = 1, option = "mako") ### Arguments * `n` - Number of colors to generate. * `alpha` - Transparency level. * `begin` - The starting point of the color scale. * `end` - The ending point of the color scale. * `option` - The color palette option to use. ## turbo() ### Description Generates the turbo color palette. ### Usage turbo(n, alpha = 1, begin = 0, end = 1, option = "turbo") ### Arguments * `n` - Number of colors to generate. * `alpha` - Transparency level. * `begin` - The starting point of the color scale. * `end` - The ending point of the color scale. * `option` - The color palette option to use. ``` -------------------------------- ### viridisMap Source: https://github.com/sjmgarnier/viridislite/blob/master/docs/reference/viridis.html Generates a data frame containing the RGBA channels for n equally spaced colors along the selected color map. ```APIDOC ## viridisMap ### Description This function returns a data frame containing the red (R), green (G), blue (B), and alpha (alpha) channels of `n` equally spaced colors along the selected color map. It defaults to `n = 256`. ### Usage ```R viridisMap(n = 256, alpha = 1, begin = 0, end = 1, direction = 1, option = "D") ``` ### Arguments * **n** (integer) - The number of colors (\(\ge 1\)) to be in the palette. Defaults to 256. * **alpha** (numeric) - The alpha transparency, a number in \([0,1]\). * **begin** (numeric) - The (corrected) hue in \([0,1]\) at which the color map begins. * **end** (numeric) - The (corrected) hue in \([0,1]\) at which the color map ends. * **direction** (numeric) - Sets the order of colors in the scale. If 1 (default), colors are ordered from darkest to lightest. If -1, the order of colors is reversed. * **option** (character) - A character string indicating the color map option to use. Eight options are available: "magma" (or "A"), "inferno" (or "B"), "plasma" (or "C"), "viridis" (or "D"), "cividis" (or "E"), "rocket" (or "F"), "mako" (or "G"), "turbo" (or "H"). ### Value Returns a `n` lines data frame containing the red (R), green (G), blue (B) and alpha (alpha) channels of `n` equally spaced colors along the selected color map. ``` -------------------------------- ### mako Source: https://github.com/sjmgarnier/viridislite/blob/master/docs/reference/viridis.html Convenience function for the 'mako' color map. ```APIDOC ## mako ### Description Convenience function for the 'mako' color map option. Useful when the scale must be passed as a function name. ### Usage ```R mako(n, alpha = 1, begin = 0, end = 1, direction = 1) ``` ### Arguments * **n** (integer) - The number of colors (\(\ge 1\)) to be in the palette. * **alpha** (numeric) - The alpha transparency, a number in \([0,1]\). * **begin** (numeric) - The (corrected) hue in \([0,1]\) at which the color map begins. * **end** (numeric) - The (corrected) hue in \([0,1]\) at which the color map ends. * **direction** (numeric) - Sets the order of colors in the scale. If 1 (default), colors are ordered from darkest to lightest. If -1, the order of colors is reversed. ### Value Returns a character vector of color hex codes. ``` -------------------------------- ### Inferno Color Map Source: https://context7.com/sjmgarnier/viridislite/llms.txt Generates the inferno color map. Use for heatmaps or when a perceptually uniform sequential color map is needed. Can subset the map by specifying begin and end values. ```r library(viridisLite) # Heatmap using inferno m <- matrix(rnorm(400), 20, 20) image(m, col = inferno(64), main = "Heatmap with inferno") # Subset of the map to avoid near-black and near-white extremes safe_inferno <- inferno(32, begin = 0.1, end = 0.85) ``` -------------------------------- ### Generate Viridis Color Palette for ggplot2 Source: https://github.com/sjmgarnier/viridislite/blob/master/docs/reference/viridis.html Use viridis() to create a color palette for gradient fills in ggplot2 plots. Requires viridis and ggplot2 libraries. ```r library(ggplot2) library(hexbin) dat <- data.frame(x = rnorm(10000), y = rnorm(10000)) ggplot(dat, aes(x = x, y = y)) + geom_hex() + coord_fixed() + scale_fill_gradientn(colours = viridis(256, option = "D")) ``` -------------------------------- ### Cividis Color Map Source: https://context7.com/sjmgarnier/viridislite/llms.txt Generates the cividis color map, optimized for color blindness perception. Useful for accessibility-critical publications. Can generate a specified number of colors. ```r library(viridisLite) # 10 cividis colors cividis(10) # [1] "#00204DFF" "#00336FFF" "#39486BFF" "#575C6DFF" "#707173FF" # [6] "#8A8779FF" "#A69D75FF" "#C4B56CFF" "#E4CF5BFF" "#FFEA46FF" # Useful for accessibility-critical publications barplot(1:7, col = cividis(7), main = "Cividis - maximally accessible") ``` -------------------------------- ### rocket Source: https://github.com/sjmgarnier/viridislite/blob/master/docs/reference/viridis.html Convenience function for the 'rocket' color map. ```APIDOC ## rocket ### Description Convenience function for the 'rocket' color map option. Useful when the scale must be passed as a function name. ### Usage ```R rocket(n, alpha = 1, begin = 0, end = 1, direction = 1) ``` ### Arguments * **n** (integer) - The number of colors (\(\ge 1\)) to be in the palette. * **alpha** (numeric) - The alpha transparency, a number in \([0,1]\). * **begin** (numeric) - The (corrected) hue in \([0,1]\) at which the color map begins. * **end** (numeric) - The (corrected) hue in \([0,1]\) at which the color map ends. * **direction** (numeric) - Sets the order of colors in the scale. If 1 (default), colors are ordered from darkest to lightest. If -1, the order of colors is reversed. ### Value Returns a character vector of color hex codes. ``` -------------------------------- ### Color Map Data Source: https://github.com/sjmgarnier/viridislite/blob/master/docs/reference/index.html This object provides access to the underlying color map data. ```APIDOC ## viridis.map ### Description Provides access to the color map data. ### Usage viridis.map ### Details This is an object containing the data for the color maps. Specific access methods or structure are not detailed in the provided text. ```