r - delete single entries in ggplot legend -
let's following code:
x <- data.frame(a=c(1:12), b=(c(seq(0.5,11.5,1))), class=rep(c("1","2"), times= 6), blubb=rep(c("a","b"), each= 6),var=rep(c("x","y","z"), each=4)) x$grp <- paste(x$class,x$blubb) ggplot(x,aes(x=a,y=b)) + geom_point(aes(color= var, shape=grp), size=3) +scale_shape_manual(values=c(16,1,18,5))
i'd scale legend show 2 entries "a" , "b", since it's kind of double, don't know how. if use
scale_shape_manual(values=c(16,1,18,5), breaks=c(16,1), labels=c("a","b"))
it not produce error, not show scale-legend either.
any ideas? :)
the breaks need represent levels of grp
.
from documentation of breaks
in discrete_scale
:
a character vector giving breaks should appear on axis or in legend.
scale_shape_manual(values = c(16, 1, 18, 5), breaks = c("1 a", "1 b"), labels = c("a", "b"))
Comments
Post a Comment