title: How to place legends at different sides of plot (bottom and right side) with ggplot2?
body: <p>I'm trying to get a plot with two legends, one at the bottom and the other at the right side of the plot.</p>
  <pre><code>library(tidyverse)
  
  df &lt;- tibble(names = mtcars %&gt;% 
    rownames(),
    mtcars)
  
  #plot 1
  p1 &lt;- df %&gt;% 
    filter(names == &quot;Duster 360&quot; | names == &quot;Valiant&quot;) %&gt;% 
  ggplot(aes(x = as.factor(cyl), y = mpg, color = names)) +
    geom_point() +
    geom_hline(aes(yintercept = 20, linetype = &quot;a&quot;)) +
    theme(legend.position = &quot;bottom&quot;)
  
  p1
  </code></pre>
  <p><a href="https://i.stack.imgur.com/QGeRf.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QGeRf.png" alt="enter image description here" /></a></p>
  <p>Desired plot (legend should be outside of plot):</p>
  <p><a href="https://i.stack.imgur.com/aYJHq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/aYJHq.png" alt="enter image description here" /></a></p>