Can someone explain why the script below ends up overlaying black dots on top of the bubbles in the legend “leg2” and adds small grey dots to the markers in “leg1”. I am trying to get “leg2” as bubbles only and “leg1” as markers only. I am missing on something here but just can’t figure it out.
df <- data.frame(x=seq(1,10), y=seq(1,10), z=c(1,0,5,3,1,8,0,12,1,0)) %>%
mutate(z_fct=factor(z, levels=c(0,1,NA)))
p <- ggplot(df, aes(x=x, y=y)) +
geom_point(aes(size=z),
colour="grey50",
alpha=0.75,
show.legend=T) +
geom_point(aes(colour=z_fct, shape=z_fct),
size=5,
show.legend=T) +
scale_colour_manual(name="leg1", limits=factor(c(0,1), levels=c(0,1)), labels=c("N=0", "N<=1"), values=c("red", "black")) +
scale_shape_manual(name="leg1", limits=factor(c(0,1), levels=c(0,1)), labels=c("N=0", "N<=1"), values=c(4,3)) +
scale_size_area(name="leg2", limits=c(0, 15), breaks=c(3,6,9,12,15), max_size=10)