Skip to content

Instantly share code, notes, and snippets.

@pcantalupo
Last active January 29, 2023 12:19
Show Gist options
  • Save pcantalupo/800637ff1cab43079c9c17b26a9e6d7a to your computer and use it in GitHub Desktop.
Save pcantalupo/800637ff1cab43079c9c17b26a9e6d7a to your computer and use it in GitHub Desktop.
visualize display hex codes in R to see the color
# Different ways to plot Hex codes to see the color
# using 'show_col()' comes from https://datacornering.com/how-to-create-and-preview-hex-color-code-sequence-in-r/
pacman::p_load('viridis','RColorBrewer','scales')
# Display Viridis colors
colors = viridis::magma(12)
scales::show_col(colors, cex_label = 1, ncol = 4)
# Display colorRampPalette colors
getHEXcolors <- colorRampPalette(c("#1F78B4", "#FFFFFF"))
scales::show_col(getHEXcolors(100), labels = FALSE)
# Display the palettes for RColorBrewer
RColorBrewer::display.brewer.all()
RColorBrewer::display.brewer.pal(8, "RdYlBu") # or Set1, etc...
colors = RColorBrewer::brewer.pal(8, "RdYlBu")
scales::show_col(colors, cex_label = 1, ncol = 2)
# colorspace package
colorspace::demoplot(c("#1F78B4", "firebrick"), type = "bar")
colorspace::hcl_palettes(plot = TRUE)
# unikn package
library('unikn') # loads the package
seecol(pal_unikn) # view details of pal_unikn
seecol(c("#1F78B4", "firebrick"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment