I would like to create a shape that has a combination of basic and graphic ggplot graphics. The following code shows my figure using the basic R plotting functions:
t <- c(1:(24*14)) P <- 24 A <- 10 y <- 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 <- 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)")
What generates 
Most of these panels look good enough to be included in my report. However, a graph showing autocorrelation needs to be improved. This looks a lot better using ggplot:
require(ggplot2) acz <- acf(y, plot=F) acd <- 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()

However, since ggplot is not a basic graph, we cannot combine ggplot with a layout or par (mfrow). How can I replace the autocorrelation graph created on the base graph with the generated ggplot? I know that I can use grid.arrange if all my drawings were done with ggplot, but how to do it if only one of the graphs is generated in ggplot?
r plot ggplot2 base biwavelet
KatyB Jan 02 '13 at 15:15 2013-01-02 15:15
source share