Created
October 24, 2012 03:19
-
-
Save mollietaylor/3943476 to your computer and use it in GitHub Desktop.
Palettes in R
This file contains hidden or 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
palette() | |
# it's fine for your vector to include a mixture of hex triplets and R color names: | |
colors <- c("#A7A7A7", | |
"dodgerblue", | |
"firebrick", | |
"forestgreen", | |
"gold") | |
hist(discoveries, | |
col = colors) | |
hist(discoveries, | |
col = colors[1]) | |
abline(v = mean(discoveries), | |
col = colors[2], | |
lwd = 5) | |
abline(v = median(discoveries), | |
col = colors[3], | |
lwd = 5) | |
abline(v = min(discoveries), | |
col = colors[4], | |
lwd = 5) | |
abline(v = max(discoveries), | |
col = colors[5], | |
lwd = 5) | |
legend(x = "topright", # location of legend within plot area | |
c("Mean", "Median", "Minimum", "Maximum"), | |
col = colors[2:5], | |
lwd = 5) | |
?rainbow | |
rainbowcols <- rainbow(6, s = 0.5) | |
hist(discoveries, | |
col = rainbowcols) | |
heatcols <- heat.colors(6) | |
hist(discoveries, | |
col = heatcols) | |
library(RColorBrewer) | |
darkcols <- brewer.pal(8, "Dark2") | |
hist(discoveries, | |
col = darkcols[1:2]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment