title: Best way to export ggplot2 graphs to a Word document?
body: <p>I have created some awesome graphs that I want to export to my Word document. Yea, should write in Markdown but... you know... someday!</p>
  <p>However, how do I resize the graphs to the right dimensions while labels stay &quot;within&quot; the perimeter? See the following examples (code is at the end of the document).</p>
  <p>I want to insert the following graph into my word document:</p>
  <p><a href="https://i.stack.imgur.com/YpWzQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YpWzQ.png" alt="Test picture" /></a></p>
  <p>Looks great! Not when I insert it into the document:</p>
  <p><a href="https://i.stack.imgur.com/SEwry.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SEwry.jpg" alt="Word screenshot" /></a></p>
  <p>Labels are two tiny, and I would love to stretch it vertically, so the width is greater than the height. So I managed to produce this:</p>
  <p><a href="https://i.stack.imgur.com/bdzSF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bdzSF.png" alt="enter image description here" /></a></p>
  <p>And this is were I am stuck. How do I keep the labels within the perimeters? And is there a better way to &quot;fit&quot; the word document than guessing correct dimensions?</p>
  <p>Thanks!</p>
  <p>This is the code:</p>
  <pre><code>library(ggplot2)
  
  df &lt;- mpg # Load sample data
  
  # First test graph 
  ggplot(data = df, mapping = aes(cyl, hwy)) +
    geom_smooth() +
    geom_point() +
    geom_point() +
    labs(y = &quot;This is just one very long label to prove a point ..... 1234&quot;,
         x = &quot;Cyl&quot;) +
    theme_classic() +
    theme(legend.title = element_blank())
  
  ggsave(&quot;test1.png&quot;)
  
  # Modified test graph to add fit the Word document
  
  ggplot(data = df, mapping = aes(cyl, hwy)) +
    geom_smooth() +
    geom_point() +
    geom_point() +
    labs(y = &quot;This is just one very long label to prove a point ..... 1234&quot;,
         x = &quot;Cyl&quot;) +
    theme_classic(base_size = 12) + # SIZE CHANGED
    theme(legend.title = element_blank())
  
  ggsave(&quot;test2.png&quot;, width = 8, height = 4) # DIMENSIONS DEFINED
  </code></pre>