`fill` scale is not shown in the legend
ggplot2, r
Solution
I know this is an old thread, but I ran into this exact problem and want to post this here for others like me. While the accepted answer works, the less risky, cleaner method is:
library(ggplot2)
ggplot(data=df, mapping = aes(x=xx, y=yy)) +
geom_point(aes(shape=type3, fill=type2), size=5) +
scale_shape_manual(values=c(24,25,21)) +
scale_fill_manual(values=c(a='green',b='red'))+
guides(fill=guide_legend(override.aes=list(shape=21)))
The key is to change the shape in the legend to one of those that can have a 'fill'.
Problem
Here is my dummy code: ``` set.seed(1) df <- data.frame(xx=sample(10,6), yy=sample(10,6), type2=c('a','b','a','a','b','b'), type3=c('A','C','B','A','B','C') ) ggplot(data=df, mapping = aes(x=xx, y=yy)) + geom_point(aes(shape=type3, fill=type2), size=5) + scale_shape_manual(values=c(24,25,21)) + scale_fill_manual(values=c('green', 'red')) ``` Resulting plot has a legend but it's 'type2' section doesn't reflect scale of `fill` value - is it by design?