title: Get width of plot area in ggplot2
body: <p>Is there any way to get the width of the plot area in the grid window? It grows or shrinks, for instance, if <code>plot.margin</code> is changed or if the y-axis labels' font-size is increased. Is is hidden somewhere in <code>str(p)</code>?</p>
  
  <p>Any size measure would work. I need to be able to measure the relative change in the width of the plot area in different scenarios such as change of y-axis labels' font-size.</p>
  
  <p><img src="https://i.stack.imgur.com/7HCXE.jpg" alt="enter image description here"></p>
  
  <pre><code>df = data.frame(x = (1:3),One=c(12, 8, 13),Two=c(13, 7, 11),Three=c(11, 9, 11))
  df.melt = melt(df, id.vars="x")
  
  p = ggplot(df.melt, aes(x=x, y=value, color=variable)) + 
    geom_line() +
    coord_cartesian(xlim=c(min(df.melt$x),max(df.melt$x))) +
    theme(legend.position="none", plot.margin = unit(c(1, 4, 1, 1), "cm")) 
  p
  </code></pre>
  
  <hr>
  
  <p>UPDATE – To clarify: Please help me calculate <code>a/b</code>.</p>
  
  <p><img src="https://i.stack.imgur.com/0atFg.jpg" alt="enter image description here"></p>
  
  <pre><code>p = ggplot(df.melt, aes(x=x, y=value, color=variable)) + 
    geom_line() + coord_cartesian(xlim=c(min(df.melt$x),max(df.melt$x))) +
    theme(legend.position="none")
  
  p1 = p + theme(plot.margin=unit(c(1,1,1,1),"cm"), axis.text.y=element_text(size=10))
  p2 = p + theme(plot.margin=unit(c(1,1,1,2),"cm"), axis.text.y=element_text(size=30))
  grid.arrange(p1, p2, ncol=2)
  </code></pre>