title: Combine base and ggplot graphics in R figure window
body: <p>I would like to generate a figure that has a combination of base and ggplot graphics. The following code shows my figure using the base plotting functions of R:</p>
  
  <pre><code>t &lt;- c(1:(24*14)) 
  P &lt;- 24 
  A &lt;- 10 
  y &lt;- A*sin(2*pi*t/P)+20
  
  par(mfrow=c(2,2))
  plot(y,type = "l",xlab = "Time (hours)",ylab = "Amplitude",main = "Time series")
  acf(y,main = "Autocorrelation",xlab = "Lag (hours)", ylab = "ACF")
  spectrum(y,method = "ar",main = "Spectral density function", 
           xlab = "Frequency (cycles per hour)",ylab = "Spectrum")
  require(biwavelet)
  t1 &lt;- cbind(t, y)
  wt.t1=wt(t1)
  plot(wt.t1, plot.cb=FALSE, plot.phase=FALSE,main = "Continuous wavelet transform",
       ylab = "Period (hours)",xlab = "Time (hours)")
  </code></pre>
  
  <p>Which generates
  <img src="https://i.stack.imgur.com/l9HXq.png" alt="enter image description here"></p>
  
  <p>Most of these panels look sufficient for me to include in my report. However, the plot showing the autocorrelation needs to be improved. This looks much better by using ggplot:</p>
  
  <pre><code>require(ggplot2)
  acz &lt;- acf(y, plot=F)
  acd &lt;- data.frame(lag=acz$lag, acf=acz$acf)
  ggplot(acd, aes(lag, acf)) + geom_area(fill="grey") +
    geom_hline(yintercept=c(0.05, -0.05), linetype="dashed") +
    theme_bw()
  </code></pre>
  
  <p><img src="https://i.stack.imgur.com/IEuQH.png" alt="enter image description here"></p>
  
  <p>However, seeing as ggplot is not a base graphic, we cannot combine ggplot with layout or par(mfrow). How could I replace the autocorrelation plot generated from the base graphics with the one generated by ggplot? I know I can use grid.arrange if all of my figures were made with ggplot but how do I do this if only one of the plots are generated in ggplot?</p>