4

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

enter image description here

ggplot(d, aes(x, y)) + geom_point(aes(colour = var1, size = var2)) + 
  theme(legend.position = "bottom",
        legend.box = "vertical") 

figure 2

enter image description here

jazzurro
  • 23,179
  • 35
  • 66
  • 76
vwelty
  • 41
  • 1
  • 4
  • 1
    Have you seen [**this question**](https://stackoverflow.com/questions/13143894/how-do-i-position-two-legends-independently-in-ggplot)? – jazzurro Feb 18 '18 at 02:39
  • I had not, thanks! I must have not been using the right search terms :) Thanks for the edit with the figures too. – vwelty Feb 18 '18 at 02:51
  • You are welcome. If you think the question solves your situation, you may want to remove your question. Otherwise, someone may mark it as duplication. – jazzurro Feb 18 '18 at 03:04

0 Answers0