用不同的xlab对齐图表 [英] align graphs with different xlab

查看:138
本文介绍了用不同的xlab对齐图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何将所有这四个图形对齐在一起,但是它们都是在同一个x轴级别对齐的。



这是我迄今为止所做的。 / p>

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

我的意思是,我需要将所有图表与废水化学物质水平对齐

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

解决方案

尝试将它们转换为grobs并将高度设置为最长的y文本名称。

  insec < -  ggplotGrob(insec)
废物<-ggplotGrob(浪费)
草药< - ggplotGrob(herb)
fung< - ggplotGrob(f ung)
insec $高度< - 浪费$高度
草药$高度< - 浪费$高度
fung $高度< - 浪费$高度

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


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/

解决方案

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

这篇关于用不同的xlab对齐图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆