Skip to content

Instantly share code, notes, and snippets.

@jeffreyiacono
Last active August 29, 2015 14:15
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 jeffreyiacono/804f6feda2707c4234fe to your computer and use it in GitHub Desktop.
Save jeffreyiacono/804f6feda2707c4234fe to your computer and use it in GitHub Desktop.
R plots with manual color scale
d <- rnorm(1000)
df <- data.frame(x = seq(1, length(d), by = 1), y = d)
df$zscore <- (df$y - mean(df$y, na.rm = TRUE)) / sd(df$y, na.rm = TRUE)
ggplot(df, aes(x = x, y = y, group = abs(zscore) >= 1.95)) + geom_point(aes(color = abs(zscore) >= 1.95))
ggplot(df, aes(x = x, y = y, group = abs(zscore) >= 1.95)) + geom_point(aes(color = abs(zscore) >= 1.95)) + scale_color_manual(values = c("FALSE" = "grey", "TRUE" = "red"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment