3

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:

enter image description here

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?

2
  • 1
    I find tasks like this easier with nesting arrangeGrob inside grid.arrange (both from the gridExtra package). Commented Jan 15, 2014 at 10:25
  • Thanks, but how can I use them? Commented Jan 15, 2014 at 11:06

1 Answer 1

4

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)))

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.