title: How do I properly resize all aspects of a ggplot in R, including the legend?
body: <p>I'm making scatterplots in ggplot2 and then using ggsave to export PDFs of specific widths and heights. However, the figure legend never gets properly resized with ggsave (its borders don't stay within the plot). Is there another way to simultaneously resize all parts of a ggplot for easy exporting? I've also tried using pdf(), but the same problem occurs.</p>
  
  <p>Here is an example of what's going on using iris:</p>
  
  <pre><code>data(iris)
  
  test &lt;- ggplot(iris, aes(x = iris$Sepal.Length, y = iris$Sepal.Width, 
    colour = iris$Species)) + 
    geom_point(size = .1) +
    theme(panel.grid.major = element_blank(), 
      panel.grid.minor = element_blank(), panel.border = element_blank(),
      panel.background = element_blank(), 
      axis.line = element_line(colour = "black", size = .8), 
      legend.key=element_blank(),
      axis.ticks = element_line(colour = "black", size = .6), 
      axis.text=element_text(size=6, colour = "black"), 
      plot.title = element_text(hjust = 0.0, size = 6, colour = "black"), 
      axis.title=element_text(size= 6), 
      legend.text=element_text(size = 6),
      legend.title=element_text(size = 6, face = "bold"),
      legend.position = c(.9, .15)) + labs(colour = "Species")
  
  ##saving plot with no resizing
  ggsave(plot = test, file = "NoResize.pdf", dpi = 600, family = "ArialMT")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/bYWSL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bYWSL.png" alt="NotResized"></a></p>
  
  <pre><code>##saving plot with resizing results in relatively larger legend
  ggsave(plot = test, file = "Resize.pdf", device = "pdf", width = 3.5, 
      height = 3, units = "in", dpi = 600, family = "ArialMT")
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/uxkQG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uxkQG.png" alt="Resized"></a></p>
  
  <p>The legend seems to be changing, but it seems to get relatively bigger than the other aspects of the plot, such that it no longer fits within the plot axes.</p>