Skip to content

Instantly share code, notes, and snippets.

@alexander-matz
Created October 11, 2018 14:27
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alexander-matz/920be616e08445427f872d6bd8d801cd to your computer and use it in GitHub Desktop.
Save alexander-matz/920be616e08445427f872d6bd8d801cd to your computer and use it in GitHub Desktop.
Nice Graph Colors from the Graphiq Blog
# Color palettes that actually look good from 1 .. 12 colors
# Taken from: https://blog.graphiq.com/finding-the-right-color-palettes-for-data-visualizations-fcd4e707a283
graphiq <- function (n, option = 'warm') {
if (n < 1 || n > 12) stop('colors only defined for n = 1..12');
if (option == 'warm') {
return(switch(n,
c("#FDB25F"),
c("#FFC96B", "#F47942"),
c("#FFC96B", "#F47942", "#AB412C"),
c("#FFD773", "#F99851", "#EF5833", "#923E2D"),
c("#FFE67A", "#FCAF5E", "#F47942", "#DA492D", "#773A2D"),
c("#FFE77E", "#FEBD65", "#F78F4D", "#F16137", "#C1452C", "#6F382E"),
c("#FFE782", "#FFC76A", "#FAA055", "#F47942", "#EF512F", "#AE422C", "#67382E"),
c("#FFE886", "#FFD06F", "#FBAD5D", "#F68A4B", "#F16739", "#DE4A2D", "#A0402C", "#5F362F"),
c("#FFE98B", "#FFD873", "#FEB862", "#F99851", "#F47942", "#EF5833", "#CA462D", "#913D2D", "#573530"),
c("#FFE98E", "#FFDF76", "#FFC267", "#FAA458", "#F68749", "#F26A3A", "#EE4C2D", "#B9442C", "#843C2D", "#4F3330"),
c("#FFE98E", "#FFE278", "#FFC76A", "#FBAD5D", "#F8934F", "#F47942", "#F05D35", "#DE4A2D", "#AE422C", "#7F3B2D", "#4F3330"),
c("#FFE98E", "#FFE479", "#FFE479", "#FEB460", "#FA9C53", "#F58547", "#F58547", "#EE5531", "#D1492D", "#A5402C", "#7A3A2D", "#4F3330")))
} else if (option == 'cool') {
return(switch(n,
c("#41BED1"),
c("#78CCCF", "#0B88B4"),
c("#78CCCF", "#0B88B4", "#00357E"),
c("#96D5CD", "#0CAAC9", "#07669E", "#002C71"),
c("#B2DFCC", "#3BBCD0", "#0B88B4", "#044F8F", "#042561"),
c("#BAE0CD", "#5CC5CF", "#0DA0C3", "#096FA4", "#044186", "#05255C"),
c("#C3E2CC", "#75CBCF", "#10B1CE", "#0B88B4", "#0B88B4", "#01377F", "#052257"),
c("#CCE5CC", "#86D1CE", "#33BBD1", "#0C9AC0", "#0A75A7", "#065090", "#002F79", "#051F53"),
c("#D4E8CC", "#96D5CD", "#52C2D0", "#0CAAC9", "#0B88B4", "#07669E", "#034589", "#012B70", "#061D4E"),
c("#DCEBCB", "#A3DACD", "#67C7CF", "#0DB6D1", "#0B97BE", "#0B78A9", "#065A96", "#023D83", "#042868", "#061C49"),
c("#DCEBCB", "#A9DCCD", "#75CBCF", "#33BBD1", "#33BBD1", "#33BBD1", "#096BA2", "#065090", "#01377F", "#032766", "#032766"),
c("#DCEBCB", "#AEDDCD", "#7ECECE", "#48C0D1", "#10ADCC", "#0B94BC", "#0B7BAB", "#09639B", "#034A8B", "#00337C", "#032663", "#061C49")))
} else if (option == 'neon') {
return(switch(n,
c("#F3648B"),
c("#F78495", "#AD3E8C"),
c("#F78495", "#AD3E8C", "#502370"),
c("#F9989B", "#DE4C86", "#7D3392", "#461E63"),
c("#FCACA4", "#F2618A", "#AD3E8C", "#612B8A", "#3C1955"),
c("#FDB3A5", "#F5738F", "#D04888", "#8A3590", "#58277C", "#3A1951"),
c("#FEB9A7", "#F68294", "#EA5084", "#AD3E8C", "#703093", "#512472", "#37164C"),
c("#FFBFAA", "#F88F98", "#F25E89", "#C84688", "#93378F", "#632C8C", "#4B2069", "#331548"),
c("#FFC5AC", "#F9999C", "#F46E8D", "#DE4C86", "#AD3E8C", "#7C3292", "#5B2981", "#451E62", "#301443"),
c("#FFCBAE", "#FAA2A0", "#F57A91", "#F05384", "#C44488", "#97388E", "#692F94", "#552578", "#411C5C", "#2D133F"),
c("#FFCBAE", "#FBA6A2", "#F68294", "#F25E89", "#D64A87", "#AD3E8C", "#853491", "#632C8C", "#512472", "#3F1B59", "#2D133F"),
c("#FFCBAE", "#FBAAA3", "#F78997", "#F3688C", "#E54F85", "#BF4489", "#9C398D", "#753193", "#5E2985", "#4D226D", "#3D1A57", "#2D133F")))
} else {
stop(paste('invalid option: ', option, '. options: warm, cool, neon', sep=''))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment