Last active
January 29, 2023 12:19
-
-
Save pcantalupo/800637ff1cab43079c9c17b26a9e6d7a to your computer and use it in GitHub Desktop.
visualize display hex codes in R to see the color
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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