[英]call a vector of names for grid.arrange
lets say I have a list called ALL
with 40 elements, each of which is a ggplot
. 可以说我有一个名为ALL
的列表,其中包含40个元素,每个元素都是一个ggplot
。
if i want to plot one of these i can do 如果我想绘制其中之一,我可以做
ALL[[1]]
or 要么
print(ALL)
if i want to plot them all together i can do 如果我想把它们全部画出来,我可以做
grid.arrange(ALL[[1]] ,ALL[[2]], ALL[[3]], .... )
or 要么
grid.arrange(ALL[[names(ALL)[1]]] ,ALL[[names(ALL)[2]]], ALL[[names(ALL)[3]]], .... )
This is really tiring with many list elements. 许多列表元素确实很累人。 But i cannot figure out how to just call grid.arrange
to plot all plots. 但是我不知道如何只调用grid.arrange
来绘制所有图。 I don't want to apply
over the list because i want multiple plots on the same page. 我不想apply
在清单上,因为我要在同一页面上绘制多个图。
Calling 40 plots to grid.arrange
may seem a lot but they are small plots and even for 1:10 plots on a page this is a lot of typing!!!! 调用40个地块到grid.arrange
可能看起来很多,但是它们是小图,即使页面上以1:10的grid.arrange
也很麻烦!
Whenever you've got a list (here your ALL
) whose elements are the arguments you'd like passed in to a function (here grid.arrange
), you can use do.call
. 只要有一个列表(这里是ALL
),其元素是要传递给函数(这里是grid.arrange
)的参数,就可以使用do.call
。
This should do the trick: 这应该可以解决问题:
## Equivalent to grid.arrange(ALL[[1]], ALL[[2]], ..., ALL[[n]])
do.call(grid.arrange, ALL)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.