| Title: | Vincent van Gogh Colour Palette Generator |
|---|---|
| Description: | Provides 'ggplot2'-compatible colour palettes inspired by Vincent van Gogh's paintings. Each palette contains five colours, manually selected by hexadecimal values. Includes tools for assessing colour vision deficiency (CVD) accessibility. |
| Authors: | Cheryl Isabella Lim [aut, cre] |
| Maintainer: | Cheryl Isabella Lim <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.1.3 |
| Built: | 2026-05-11 05:51:15 UTC |
| Source: | https://github.com/cherylisabella/vangogh |
Runs CVD accessibility checks across all Van Gogh palettes and returns a summary data frame. Useful for generating documentation and identifying the most accessible palettes.
check_all_vangogh_cvd(simulate = FALSE)check_all_vangogh_cvd(simulate = FALSE)
simulate |
Logical. If TRUE, displays simulations for each palette. Default FALSE. |
A data frame with CVD scores for all palettes
## Not run: # Get scores for all palettes all_scores <- check_all_vangogh_cvd() # Find the most accessible palettes library(dplyr) all_scores %>% group_by(palette) %>% summarise(avg_distance = mean(min_distance)) %>% arrange(desc(avg_distance)) ## End(Not run)## Not run: # Get scores for all palettes all_scores <- check_all_vangogh_cvd() # Find the most accessible palettes library(dplyr) all_scores %>% group_by(palette) %>% summarise(avg_distance = mean(min_distance)) %>% arrange(desc(avg_distance)) ## End(Not run)
Uses colorspace to simulate common forms of colorblindness.
check_palette(name, type = "discrete", n = NULL)check_palette(name, type = "discrete", n = NULL)
name |
Palette name (character) |
type |
Either "discrete" or "continuous" (default "discrete") |
n |
Number of colors for continuous palettes |
## Not run: vangogh::check_palette("StarryNight") ## End(Not run)## Not run: vangogh::check_palette("StarryNight") ## End(Not run)
Simulates how a Van Gogh palette appears under different types of color vision deficiency and provides accessibility scores. This function complements the existing check_palette() function by adding visual simulation and quantitative metrics.
check_vangogh_cvd( palette_name, n = NULL, simulate = TRUE, return_scores = FALSE )check_vangogh_cvd( palette_name, n = NULL, simulate = TRUE, return_scores = FALSE )
palette_name |
Character string specifying the palette name (e.g., "StarryNight") |
n |
Integer. Number of colors to extract from palette. Default is NULL (uses all colors). |
simulate |
Logical. If TRUE, displays simulations for each CVD type. Default TRUE. |
return_scores |
Logical. If TRUE, returns detailed scoring data. Default FALSE. |
This function evaluates palette accessibility across three main types of color vision deficiency:
Deuteranopia (red-green, affects ~5% of males)
Protanopia (red-green, affects ~2% of males)
Tritanopia (blue-yellow, affects ~0.01% of population)
The function uses the colorspace package for CVD simulation and calculates minimum pairwise perceptual distance in CIELAB color space to assess distinguishability.
If return_scores = TRUE, returns a data frame with CVD scores. Otherwise, displays visual simulations and prints a summary.
## Not run: # Visual simulation of StarryNight palette check_vangogh_cvd("StarryNight") # Get detailed scores without plotting scores <- check_vangogh_cvd("Irises", simulate = FALSE, return_scores = TRUE) # Check subset of colors check_vangogh_cvd("CafeTerrace", n = 3) ## End(Not run)## Not run: # Visual simulation of StarryNight palette check_vangogh_cvd("StarryNight") # Get detailed scores without plotting scores <- check_vangogh_cvd("Irises", simulate = FALSE, return_scores = TRUE) # Check subset of colors check_vangogh_cvd("CafeTerrace", n = 3) ## End(Not run)
Compare multiple Van Gogh palettes in a facet-style visualization
compare_palettes( palettes, show_hex = TRUE, colorblind = FALSE, type = "discrete", n = NULL )compare_palettes( palettes, show_hex = TRUE, colorblind = FALSE, type = "discrete", n = NULL )
palettes |
Character vector of palette names |
show_hex |
Logical: display hex codes |
colorblind |
Logical: simulate colorblind view |
type |
"discrete" or "continuous" |
n |
Number of colors for continuous palettes |
Returns a list of Van Gogh palettes that meet minimum accessibility standards for color vision deficiency.
get_cvd_safe_palettes( min_distance = 15, cvd_types = c("deutan", "protan", "tritan") )get_cvd_safe_palettes( min_distance = 15, cvd_types = c("deutan", "protan", "tritan") )
min_distance |
Numeric. Minimum CIELAB distance threshold. Default 15. |
cvd_types |
Character vector. Which CVD types to check. Options: "deutan", "protan", "tritan". Default checks all. |
Character vector of palette names that meet the criteria
## Not run: # Get highly accessible palettes safe_palettes <- get_cvd_safe_palettes(min_distance = 20) # Use a safe palette ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point() + scale_color_vangogh(safe_palettes[1]) ## End(Not run)## Not run: # Get highly accessible palettes safe_palettes <- get_cvd_safe_palettes(min_distance = 20) # Use a safe palette ggplot(iris, aes(Sepal.Length, Sepal.Width, color = Species)) + geom_point() + scale_color_vangogh(safe_palettes[1]) ## End(Not run)
Generates markdown badges for palette CVD accessibility ratings. Useful for including in README or documentation.
print_cvd_badge(palette_name)print_cvd_badge(palette_name)
palette_name |
Character string specifying the palette name |
Character string with markdown badge code
## Not run: # Generate badge for StarryNight print_cvd_badge("StarryNight") # Generate badges for all palettes for (p in names(vangogh_palettes)) { cat(p, ": ") print_cvd_badge(p) } ## End(Not run)## Not run: # Generate badge for StarryNight print_cvd_badge("StarryNight") # Generate badges for all palettes for (p in names(vangogh_palettes)) { cat(p, ": ") print_cvd_badge(p) } ## End(Not run)
Returns the original palette (colorblind adjustment removed).
safe_vangogh_palette(name, type = "discrete", n = NULL, colorblind = FALSE)safe_vangogh_palette(name, type = "discrete", n = NULL, colorblind = FALSE)
name |
Palette name |
type |
Either "discrete" or "continuous" |
n |
Number of colors for continuous palettes |
colorblind |
Logical, kept for compatibility |
Scale color with Van Gogh palettes
scale_color_vangogh(name, discrete = TRUE, colorblind = FALSE, ...) scale_colour_vangogh(name, discrete = TRUE, colorblind = FALSE, ...)scale_color_vangogh(name, discrete = TRUE, colorblind = FALSE, ...) scale_colour_vangogh(name, discrete = TRUE, colorblind = FALSE, ...)
name |
Palette name |
discrete |
Logical: use discrete scale |
colorblind |
Logical: use colorblind-safe colors |
... |
Additional arguments to ggplot2 scale function |
Scale fill with Van Gogh palettes
scale_fill_vangogh(name, discrete = TRUE, colorblind = FALSE, ...)scale_fill_vangogh(name, discrete = TRUE, colorblind = FALSE, ...)
name |
Palette name |
discrete |
Logical: use discrete scale |
colorblind |
Logical: use colorblind-safe colors |
... |
Additional arguments to ggplot2 scale function |
Creates a summary table of CVD accessibility for all palettes, useful for documentation and choosing palettes.
summarize_cvd_accessibility()summarize_cvd_accessibility()
A data frame with palette names and overall CVD metrics
## Not run: summary <- summarize_cvd_accessibility() print(summary) # Find best palettes best <- summary[summary$overall_rating == "Excellent", ] print(best) ## End(Not run)## Not run: summary <- summarize_cvd_accessibility() print(summary) # Find best palettes best <- summary[summary$overall_rating == "Excellent", ] print(best) ## End(Not run)
Theme inspired by Van Gogh (variants)
theme_vangogh( base_size = 12, base_family = "", variant = c("classic", "light", "dark", "sketch") )theme_vangogh( base_size = 12, base_family = "", variant = c("classic", "light", "dark", "sketch") )
base_size |
numeric base font size |
base_family |
font family |
variant |
one of "classic", "light", "dark", "sketch" |
Return all Van Gogh palettes as a tidy data frame
vangogh_colors( n = NULL, type = "discrete", colorblind = FALSE, add_metadata = FALSE )vangogh_colors( n = NULL, type = "discrete", colorblind = FALSE, add_metadata = FALSE )
n |
Number of colors per palette |
type |
"discrete" or "continuous" |
colorblind |
Logical (compatibility) |
add_metadata |
Logical: compute HCL metadata if colorspace available |
Pre-computed CVD accessibility scores for all Van Gogh palettes. This data is generated by running check_all_vangogh_cvd() and is included for quick reference without requiring the colorspace package.
vangogh_cvd_scoresvangogh_cvd_scores
A data frame with CVD accessibility metrics:
Name of the Van Gogh palette
Type of colour vision deficiency
Minimum CIELAB distance between colours (higher = more distinguishable)
Rating: Poor, Fair, Good, or Excellent
Average accessibility across all CVD types
Distance interpretation:
< 10: Poor - colours may be indistinguishable
10-20: Fair - some difficulty distinguishing
20-40: Good - generally distinguishable
> 40: Excellent - highly distinguishable
## Not run: # View CVD scores data(vangogh_cvd_scores) # Find most accessible palettes palette_summary <- aggregate( min_distance ~ palette, data = vangogh_cvd_scores, FUN = mean ) palette_summary[order(-palette_summary$min_distance), ] # Filter by CVD type deutan_scores <- vangogh_cvd_scores[ vangogh_cvd_scores$cvd_type == "Deuteranopia (red-green)", ] deutan_scores[order(-deutan_scores$min_distance), ] ## End(Not run)## Not run: # View CVD scores data(vangogh_cvd_scores) # Find most accessible palettes palette_summary <- aggregate( min_distance ~ palette, data = vangogh_cvd_scores, FUN = mean ) palette_summary[order(-palette_summary$min_distance), ] # Filter by CVD type deutan_scores <- vangogh_cvd_scores[ vangogh_cvd_scores$cvd_type == "Deuteranopia (red-green)", ] deutan_scores[order(-deutan_scores$min_distance), ] ## End(Not run)
Export palettes to JSON or CSV
vangogh_export( file, format = c("json", "csv"), n = NULL, type = "discrete", add_metadata = FALSE )vangogh_export( file, format = c("json", "csv"), n = NULL, type = "discrete", add_metadata = FALSE )
file |
File path including filename |
format |
"json" or "csv" |
n |
Number of colors (for continuous palettes) |
type |
"discrete" or "continuous" |
add_metadata |
Logical: include HCL metadata if available |
Interpolate a Van Gogh palette
vangogh_interpolate(palette, n)vangogh_interpolate(palette, n)
palette |
Vector of hex colors |
n |
Number of colors desired |
These are some color palettes from a selection of Vincent van Gogh's paintings.
vangogh_palette(name, n, type = c("discrete", "continuous"))vangogh_palette(name, n, type = c("discrete", "continuous"))
name |
Name of desired palette. Choices are:
|
n |
Number of colors desired. All palettes have a standard of 5 colors. If omitted, uses all colors. |
type |
Either "continuous" or "discrete". Use "continuous" to automatically interpolate between colours. @importFrom graphics rgb rect par image text |
A vector of colors.
vangogh_palette("StarryNight") vangogh_palette("SelfPortrait") vangogh_palette("Cypresses") vangogh_palette("Cypresses", 3) # If you want a continous paletted based on the colors already found in the preset # palettes, you can interpolate between existing colours accordingly. pal <- vangogh_palette(21, name = "StarryRhone", type = "continuous")vangogh_palette("StarryNight") vangogh_palette("SelfPortrait") vangogh_palette("Cypresses") vangogh_palette("Cypresses", 3) # If you want a continous paletted based on the colors already found in the preset # palettes, you can interpolate between existing colours accordingly. pal <- vangogh_palette(21, name = "StarryRhone", type = "continuous")
Return palette info as a data frame with optional HCL
vangogh_palette_info(colorblind = FALSE, add_metadata = FALSE)vangogh_palette_info(colorblind = FALSE, add_metadata = FALSE)
colorblind |
Logical (compatibility) |
add_metadata |
Logical: compute HCL hue/chroma/luminance if colorspace is installed |
Helper function to add CVD accessibility information to your existing palette information functions.
vangogh_palette_info_with_cvd(palette_name)vangogh_palette_info_with_cvd(palette_name)
palette_name |
Character string specifying the palette name |
List with palette info and CVD scores
## Not run: # Get enhanced palette info with CVD data info <- vangogh_palette_info_with_cvd("StarryNight") print(info$cvd_accessibility$summary) ## End(Not run)## Not run: # Get enhanced palette info with CVD data info <- vangogh_palette_info_with_cvd("StarryNight") print(info$cvd_accessibility$summary) ## End(Not run)
Use vangogh_palette to construct palettes of desired length.
vangogh_palettesvangogh_palettes
An object of class list of length 15.
Suggest a palette based on number of colors
vangogh_suggest(n = 5, type = "discrete")vangogh_suggest(n = 5, type = "discrete")
n |
Number of colors needed |
type |
"discrete" or "continuous" |
Visualise a Van Gogh palette with optional colorblind simulation
viz_palette( name, show_hex = TRUE, colorblind = FALSE, type = "discrete", n = NULL )viz_palette( name, show_hex = TRUE, colorblind = FALSE, type = "discrete", n = NULL )
name |
Palette name |
show_hex |
Display hex codes (TRUE/FALSE) |
colorblind |
Show colorblind simulation (TRUE/FALSE) |
type |
Either "discrete" or "continuous" |
n |
Number of colors for continuous palettes |