使用 do.call 和 gridExtra 重新排序 ggplots 列表
reorder list of ggplots using do.call and gridExtra
我有一个 ggplots 列表,我创建为 gglist
,其中包含 ggplot1
、ggplot2
和 ggplot3
。我想这样使用 grid.arrange()
来排列它们:
do.call(grid.arrange,gglist)
但是,我想重新排序,以便它们出现在 ggplot3
、ggplot1
和 ggplot2
的序列中。我如何使用 do.call
函数做到这一点?
您应该能够使用 [c(your order)]
重新排序存储在 gglist 中的图表的排列方式
在这种情况下:
do.call(grid.arrange, gglist[c(3,1,2)])
如果您要指定图表的顺序,您甚至不必使用 do.call
,只需正常使用 grid.arrange
函数,例如:
grid.arrange(ggplot3, ggplot1, ggplot2)
我有一个 ggplots 列表,我创建为 gglist
,其中包含 ggplot1
、ggplot2
和 ggplot3
。我想这样使用 grid.arrange()
来排列它们:
do.call(grid.arrange,gglist)
但是,我想重新排序,以便它们出现在 ggplot3
、ggplot1
和 ggplot2
的序列中。我如何使用 do.call
函数做到这一点?
您应该能够使用 [c(your order)]
在这种情况下:
do.call(grid.arrange, gglist[c(3,1,2)])
如果您要指定图表的顺序,您甚至不必使用 do.call
,只需正常使用 grid.arrange
函数,例如:
grid.arrange(ggplot3, ggplot1, ggplot2)