2

How I can align all these four graphs together but been all of them alignment at the same x axis level.

This is what I have done so far.

grid.newpage()
vplayout <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y)
pushViewport(viewport(layout = grid.layout(1, 4)))
print(insec, vp=vplayout(1,1))
print(waste, vp=vplayout(1,2))
print(herb, vp=vplayout(1,3))
print(fung, vp=vplayout(1,4))

I mean, I need all my graphs align at the level of "wastewater chemical"

http://postimg.org/image/git1zs05j/

Pedr Nton
  • 79
  • 7

1 Answers1

1

Try to convert them to grobs and set heights to the one with the longest y text names.

insec <- ggplotGrob(insec)
waste <- ggplotGrob(waste)
herb <- ggplotGrob(herb)
fung <- ggplotGrob(fung)
insec$heights <- waste$heights
herb$heights <- waste$heights
fung$heights <- waste$heights

grid.newpage()
vplayout <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y)
pushViewport(viewport(layout = grid.layout(1, 4)))
print(arrangeGrob(insec), vp=vplayout(1,1))
print(arrangeGrob(waste), vp=vplayout(1,2))
print(arrangeGrob(herb), vp=vplayout(1,3))
print(arrangeGrob(fung), vp=vplayout(1,4))
JakeC
  • 292
  • 3
  • 11