I have two legends, one from a colour
argument, and one from a fill
argument. By default, the two legends are placed on the right side of the plot. They can be moved together to the bottom of the plot with legend.position()
, but I want to keep one legend on the right and move the other to the bottom. In the (trivial) reproducible example below, I would want the var2
legend to stay on the right of the plot, and move only the var1
legend to the bottom of the plot. Is it possible to do so?
d <- data.frame(var1 = sample(1:20, 20, replace = T),
var2 = runif(20),
x = rnorm(20),
y = rnorm(20))
ggplot(d, aes(x, y)) + geom_point(aes(colour = var1, size = var2))
figure 1
ggplot(d, aes(x, y)) + geom_point(aes(colour = var1, size = var2)) +
theme(legend.position = "bottom",
legend.box = "vertical")
figure 2