title: Set the size of ggsave exactly
body: <p><code>R</code> question.</p>
  
  <p>I got so confused by the <code>width</code>, <code>height</code>, <code>dpi</code> and <code>unit</code>. </p>
  
  <p>Why the following two size different?</p>
  
  <pre><code>ggsave(filename = "foo.png",ggplot(mtcars, aes(x=wt, y=mpg)) +
      geom_point(size=2, shape=23),width = 5, height = 4, dpi = 300, units = "in", device='png')
  </code></pre>
  
  <p>and</p>
  
  <pre><code>ggsave(filename = "foo.png",ggplot(mtcars, aes(x=wt, y=mpg)) +
             geom_point(size=2, shape=23),width = 5, height = 4, dpi = 72, units = "in", device='png')
  </code></pre>
  
  <p>I set both of the picture's size 5 (inches) * 4 (inches). But why when I change the <code>dpi</code>, the size changes? </p>
  
  <p>How to understand the relationship between <code>height</code>, <code>width</code>, <code>unit</code> and <code>dpi</code>?</p>
  
  <p>Or how to translate these four parameters into unit of pixels, which is easier for me to understand?</p>