title: output a plot with appropriate width and height in r
body: <p>I have a plot combined with 6 subplots and I want to output the plot to a pdf file.</p>
  <p>But the font size is too small for human seeing.</p>
  <p>I reference this <a href="https://stackoverflow.com/questions/44711236/set-the-size-of-ggsave-exactly">website</a>.</p>
  <p>And I think maybe the problem is caused by DPI, but the plot nothing change when I give higher DPI to <code>ggsave()</code> with same <code>width</code> and <code>height</code>.</p>
  <p>I'd like to make some fake data to illustrate my question.</p>
  <pre><code>library(tidyverse)
  library(patchwork)
  set.seed(1234)
  # DATA
  
  # data 1
  type&lt;- sample(LETTERS, 5, replace = T) %&gt;% map_chr(~paste0(rep(.,7), collapse = ''))
  df0 &lt;- expand.grid(
    type = type,
    year = 2014:2018) %&gt;% 
    mutate(value = runif(25, min = 0, max = 1))
  # data 2
  name &lt;- sample(LETTERS, 58, replace = T) %&gt;% map_chr(~paste0(rep(.,7), collapse = '')) %&gt;% paste0(1:58)
  df &lt;- expand.grid(
    name = name,
    year = 2014:2018,
    month = 1:12) %&gt;% 
    mutate(value = runif(3480, min =0, max = 1),
           x.lab = paste0(year,'_', month))
  # data 3
  facet = sample(LETTERS, 5, replace = T) %&gt;% map_chr(~paste0(rep(.,7), collapse = ''))
  df2 &lt;- expand.grid(
    year = 2014:2018,
    month = 1:12,
    facet = facet) %&gt;% 
    mutate(value = runif(300, min = 0, max = 1))
  </code></pre>
  <p>Then I make 6 plots that imitate my real plot.</p>
  <pre><code># PLOT
  
  # p1 and p2
  p1_2 &lt;- df0 %&gt;% ggplot() + 
    geom_area(aes(x = year, y = value, fill = type)) +
    scale_fill_manual(values =c('#D30f8C', '#6B58A6','#FCAF17',  '#0871B9', '#00B3B1'))  +
    theme_classic()
  p1 &lt;- p1_2 +
    labs(x = 'Year', fill = 'Disease Type', tag = '(A)')
  
  p2 &lt;- p1_2 +
    labs(x = 'Year', fill = 'Disease Type', tag = '(B)')
  
  # p3 and p4
  p3_4 &lt;- df %&gt;% 
    ggplot(aes(y = name, x = x.lab, fill = value)) +
    geom_tile() + 
    theme_classic() + 
    scale_fill_continuous(limits = c(0,1))+
    theme(axis.text.x = element_blank())
  
  p3 &lt;- p3_4 +
    labs(fill = 'Incidence', y = 'Disease name', x = 'Year', tag = &quot;(E)&quot;)
  p4 &lt;- p3_4 +
    labs(fill = 'Incidence', y = 'Disease name', x = 'Year', tag = &quot;(F)&quot;)
  
  # p5 and p6
  p5_6 &lt;- ggplot(df2, 
               aes(x = month, y = year, fill = value)) +
    geom_tile(color = 'black') + 
    scale_x_continuous( breaks=seq(from = 1, to = 12, length.out = 12)) +
    coord_polar() +
    ylab(&quot;Year&quot;)+
    xlab('Month')+ labs(fill = 'Incidence') +
    facet_wrap(facet ~ ., nrow = 1, ncol = 5) +
    theme_classic()  
  
  p5 &lt;- p5_6 + labs(tag = '(C)') 
  p6 &lt;- p5_6 + labs(tag = '(D)') 
  
  # COMBINE
  
  pcwork &lt;- (p1+p3) / (p2+p4) /p5 / p6 + plot_layout(guides = 'collect')
  </code></pre>
  <p>Finally, I tried some method to output my plot but all that is not my expected.</p>
  <pre><code># OUTPUT
  
  # font too small
  # axis y text too closely in (E) and (F)
  ggsave(filename = &quot;foo.pdf&quot;, pcwork,
         width = 20, height = 30, dpi = 150, units = &quot;in&quot;, device='pdf')
  
  # the spacing between axis y text in (E) and (F) is appropriate now
  # but there is large spacing between (C) and (D)
  ggsave(filename = &quot;foo2.pdf&quot;, pcwork,
         width = 20, height = 50, dpi = 150, units = &quot;in&quot;, device='pdf', limitsize = F)
  
  # see if the font size could increase by increasing dpi:
  # nothing change
  ggsave(filename = &quot;foo3.pdf&quot;, pcwork,
         width = 20, height = 50, dpi = 150*100, units = &quot;in&quot;, device='pdf', limitsize = F)
  
  # widen the plot
  ggsave(filename = &quot;foo4.pdf&quot;, pcwork,
         width = 60, height = 30, dpi = 150*100, units = &quot;in&quot;, device='pdf', limitsize = F)
  </code></pre>
  <p>I just want every plot in <code>pcwork</code> could be full of the page with appropriate font size for human seeing. Also, the layout should like this :</p>
  <pre><code># (A) XX (E) XX
  # (B) XX (F) XX
  # (C) XXXXXXXXX
  # (D) XXXXXXXXX
  </code></pre>
  <p>Any help will be highly appreciated!</p>