Reputation: 3057
I want to have three plots. the first one one the top of the two other. I can produce the two bottom plots, but can't produce the big first on the top:
here is my code to produce this diagram:
grid.newpage()
pushViewport(viewport(layout=grid.layout(3,2)))
vplayout <- function(x,y)
viewport(layout.pos.row = x, layout.pos.col = y)
psig <- function(x, y, z){
h <- data.frame(index = c(1:length(subsignals[[x]])),
orders = subsignals[[x]])
lab <- paste("Subseries ", as.character(x), sep="")
print(qplot(index, orders, data = h, geom = "line", main=lab), vp = vplayout(y,z))
TRUE
}
psig(1,3,1); psig(2,3,2);
I have the parameter datalist
datalis<-c(#some data)
and I want to plot datalist on the top of these two plots.(it is possible that I have more than two plots at the bottom, but I want two have datalist
plot at the top of another plots
How can I do that?
Upvotes: 3
Views: 227
Reputation: 121608
Using arrangeGrob
you can do this :
library(gridExtra)
print(arrangeGrob(p1,arrangeGrob(p2 , p3,nrow=1), nrow=2,heights=c(3, 1)))
For example:
library(gridExtra)
library(ggplot2)
p0 <- ggplot(cars)+geom_line(aes(speed,dist))
print(arrangeGrob(p0,arrangeGrob(p0 , p0,nrow=1), nrow=2,
heights=c(3, 1)))
Upvotes: 4