0

I´m starting with lattice. I have several plots and I want to dispose then with grid.arrange

Here´s an example for two graphs

graph1<-useOuterStrips(barchart(value1~Var1|Var2+Var3,data=table.df, ylab=NULL)
graph2<-useOuterStrips(barchart(value2~Var1|Var2+Var3,data=table.df, ylab=NULL)
grid.arrange(graph1,graph2, nrow=2, ncol=2, left=("percentage"))

It works well, however I would like to change the heighs of each rown on the grid (to expand the graphs). I have tried to inlcude the argument heighs on grid.arrange but doesn´t seens to do the job.

Any suggestion?

Francisco
  • 381
  • 3
  • 4
  • 13

1 Answers1

2

The correct argument to pass to grid.arrange and be passed to grid.layout is heights.

That being said, if you send it identical heights for all cells in the layout, the heights will stay the same. You may need to increase the size of your plotting device.

If you want different heights for each row you can.

Using the example from ?barchart

x <-barchart(yield ~ variety | site, data = barley,
          groups = year, layout = c(1,6), stack = TRUE,
          auto.key = list(space = "right"),
          ylab = "Barley Yield (bushels/acre)",
          scales = list(x = list(rot = 45)))
y <-barchart(yield ~ variety | site, data = barley,
          groups = year, layout = c(1,6), stack = TRUE,
          auto.key = list(space = "right"),
          ylab = "Barley Yield (bushels/acre)",
          scales = list(x = list(rot = 45)))

grid.arrange(x,y,ncol=1, heights = c(1.5,2))

enter image description here

Which is ugly and useless, but shows the concept.

Community
  • 1
  • 1
mnel
  • 113,303
  • 27
  • 265
  • 254
  • Hi mnel. Yes, this example ilustrates perfectly my problem. Taking from here, if I wanted to decrease the size between this two graphs (the ploting area?) what should I do? – Francisco Dec 21 '12 at 10:31