Skip to content

Instantly share code, notes, and snippets.

@mollietaylor
Created October 24, 2012 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mollietaylor/3943476 to your computer and use it in GitHub Desktop.
Save mollietaylor/3943476 to your computer and use it in GitHub Desktop.
Palettes in R
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