Skip to content

Instantly share code, notes, and snippets.

@rBatt
Created November 23, 2015 22:04
Show Gist options
  • Save rBatt/6d277056c24a8515cd0c to your computer and use it in GitHub Desktop.
Save rBatt/6d277056c24a8515cd0c to your computer and use it in GitHub Desktop.
add heat map colors to plot
zCol <- function(nCols, Z){
cols <- colorRampPalette(c("#000099", "#00FEFF", "#45FE4F", "#FCFF00", "#FF9400", "#FF3100"))(nCols)
colVec_ind <- cut(Z, breaks=nCols)
colVec <- cols[colVec_ind]
}
# Example
X <- rnorm(1E3)
Y <- rnorm(1E3)
Z <- X*Y
plot(X, Y, col=zCol(15, Z))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment