Created
April 25, 2013 01:08
-
-
Save jimjh/5456801 to your computer and use it in GitHub Desktop.
An easier way to build custom color gradients with R.
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
color.grad <- function(input, bins=10) { | |
colors <- c('#FFFFFF', heat.colors(bins-1)) # white for 0/NA | |
input[is.na(input)] <- 0 # replace NA with 0 | |
colors[cut(input, bins, labels=F)] # break up into bins, project colors | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment