discrete color scale limits do not remove geoms #722

Closed
corecode opened this Issue Nov 19, 2012 · 2 comments

Comments

Projects
None yet
2 participants

setting limits on a discrete color scale does not remove geoms.

This does not work:

d <- data.frame(x=1:9, y=1:9, z=factor(rep(c(1,2,3), 3)))
p <- ggplot(aes(x=x, y=y, color=z), data=d)  + geom_point(size=5)
p + scale_color_discrete(limits=c(1, 2))

This works:

p + scale_color_manual(limits=c(1,2), values=c('red', 'blue'))
Owner

hadley commented Feb 24, 2014

See na.value

@hadley hadley closed this Feb 24, 2014

Slightly more verbose explanation (in case somebody uses this as reference):

d <- data.frame(x=1:9, y=1:9, z=factor(rep(c(1,2,3), 3)))
p <- ggplot(aes(x=x, y=y, color=z), data=d)  + geom_point(size=5)
p + scale_color_discrete(limits=c(1, 2), na.value=NA)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment