title: How to remove border around legend and variable name in ggplot?
body: <p>I'm trying to remove the border around the legend in my barchart plot as well as the name variable. I only want the color and associated label.</p>
  
  <p><a href="https://i.stack.imgur.com/Dl8G2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dl8G2.png" alt="enter image description here"></a></p>
  
  <p>below is the relevant code I'm using.</p>
  
  <pre><code>p = ggplot(df, aes(Type, value, fill=variable)) +
    geom_bar(position="dodge",stat="identity") +  
    ...
  theme(
    legend.position="top",
    legend.margin=margin(t = 0, unit='cm'), 
    legend.box.background = element_rect(fill = "transparent"),
    legend.key = element_rect(colour = NA),
    axis.title.x=element_blank(),
    axis.ticks.x=element_blank(),
    axis.title.y=element_blank(),
    axis.ticks.y=element_blank(),
    axis.text.y=element_blank(),
    plot.title = element_text(hjust = 0.5),
    panel.background = element_rect(fill = "transparent"),
    plot.background = element_rect(fill = "transparent"),
    panel.grid.major = element_blank(), 
    panel.grid.minor = element_blank() 
  )
  </code></pre>
  
  <p>I've tried a few different things, but nothing has worked so far.</p>