title: Panel transparency in ggplot
body: <p>I want to my output ggplot2 graphics have transparent border (panel) but white (not transparent) plot background.</p>
  
  <p>I tried these two options</p>
  
  <pre><code>d &lt;- rnorm(100)
  df &lt;- data.frame(y = d, x = 1)
  p &lt;- ggplot(df) + stat_boxplot(aes(x = x, y = y)) 
  # first option
  p &lt;- p + theme(
    panel.background = element_rect(fill = "transparent", colour = NA), 
    panel.grid.minor = element_blank(), 
    panel.grid.major = element_blank()
  )
  # second option
  # p &lt;- p + theme(
  #   panel.background = element_rect(fill = "transparent", colour = NA), 
  #   panel.grid.minor = element_blank(), 
  #   panel.grid.major = element_blank(),
  #   plot.background = element_rect(fill = "transparent", colour = NA)
  # )
  
  png('plot.png', width = 300, height = 300, units = "px", bg = "transparent")
  print(p)
  dev.off()
  </code></pre>
  
  <p>But I got unsatisfactory output
  <a href="https://i.stack.imgur.com/pnSaH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pnSaH.png" alt="enter image description here"></a></p>