2015-05-08 363 views
3

我想知道如何安排一个grob对象(表)到另一个中。请看下面的例子:如何在r中使用ggplot2和gridExtra包安排一个grob对象

library(ggplot2) 
library(gridExtra) 

p1 <- qplot(data=mtcars, x = mpg, y = hp, facets = ~ hp, geom="point") 
t1 <- tableGrob(head(mtcars)) 
print(arrangeGrob(p1, t1)) 

这产生了:

Plot 01

我想要做的就是地方台其他对象是这样的:

Desired Result

这是可能的使用gridArrange或者可能是grid和/或gridExtra的其他方法?

+1

[**此**](http://stackoverflow.com/questions/12318120/adding-table-within-the (gplot-in-r/12318578#12318578)可能是一个开始。我知道还有一些关于明确地将“某物”放置在一个空的面板中的帖子。现在找不到它们... – Henrik

+1

这是我正在考虑的那个:[**如何使用由facet_wrap生成的空白空间**](http://stackoverflow.com/questions/22450765/how-使用的空空间产生的逐面缠绕/ 22451866#22451866)。 – Henrik

回答

4

这里是一种可能性使用格功能:

png("SO.png", width = 1440, height = 720) 

plot(p1) 

vp <- viewport(x = 0.95, y = 0.02, 
       width = unit(0.4, "npc"), height = unit(0.2, "npc"), 
       just = c("right", "bottom")) 
pushViewport(vp) 
grid.draw(t1) 

dev.off() 

resulting plot

相关问题