Skip to content

Instantly share code, notes, and snippets.

@emhart
Created October 4, 2012 20:10
Show Gist options
  • Save emhart/3836105 to your computer and use it in GitHub Desktop.
Save emhart/3836105 to your computer and use it in GitHub Desktop.
Add continuous like colors to a discrete variable
gs.pal <- colorRampPalette(c("red","blue"),bias=.1,space="rgb")
x <- rnorm(100)
dat <- data.frame(cbind(x))
dat$fac <- as.factor(sort(rep(1:5,20)))
dat$y <- x * as.numeric(dat$fac)
ggplot(dat,aes(x=x,y=y,colour=fac))+geom_point()+scale_colour_manual(values=gs.pal(5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment