title: ggplot2: how to separate geom_polygon and geom_line in legend keys?
body: <p>I want to: </p>
  
  <ul>
  <li>remove the line inside geom_polygon legend key and </li>
  <li>remove the border around the geom_line legend key.   </li>
  </ul>
  
  <p>The desired output would be </p>
  
  <p><a href="https://i.stack.imgur.com/ZdwYp.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZdwYp.png" alt="enter image description here"></a></p>
  
  <p>My failed attempt so far. Thank you in advance for any help!</p>
  
  <pre><code>library(ggplot2)
  
  set.seed(1337)
  
  dat &lt;- structure(list(id = structure(c(2L, 2L, 2L, 2L), 
                                      .Label = c("1.1", "1.2", "1.3", "2.1", "2.2", "2.3"), 
                                      class = "factor"), 
                       value = c(3.1, 3.1, 3.1, 3.1),
                       x = c(2.2, 1.1, 1.2, 2.5), 
                       y = c(0.5, 1, 2.1, 1.7)), 
                  class = "data.frame", 
                  row.names = c(NA, -4L))
  
  line &lt;- data.frame(
    x = cumsum(runif(50, max = 0.1)),
    y = cumsum(runif(50, max = 0.1))
  )
  
  ggplot(dat, aes(x = x, y = y)) +
    geom_polygon(aes(color = "Border", group = id), fill = NA) +
    geom_line(data = line, aes(colour = "Line"), size = 1) +
    theme(legend.background = element_rect(fill = "transparent"), 
          legend.box.background = element_rect(fill = "transparent", colour = NA),
          legend.key = element_rect(fill = "transparent"))
  </code></pre>
  
  <p><img src="https://i.imgur.com/fBSQigO.png" alt=""></p>