How can I arrange an arbitrary number of ggplots using grid.arrange?

后端 未结 3 1896
死守一世寂寞
死守一世寂寞 2020-11-28 01:31

This is cross-posted on the ggplot2 google group

My situation is that I\'m working on a function that outputs an arbitrary number of plots

3条回答
  •  萌比男神i
    2020-11-28 02:17

    You're ALMOST there! The problem is that do.call expects your args to be in a named list object. You've put them in the list, but as character strings, not named list items.

    I think this should work:

    args.list <- c(plot.list, 2,2)
    names(args.list) <- c("x", "y", "z", "nrow", "ncol")
    

    as Ben and Joshua pointed out in the comments, I could have assigned names when I created the list:

    args.list <- c(plot.list,list(nrow=2,ncol=2))
    

    or

    args.list <- list(x=x, y=y, z=x, nrow=2, ncol=2)
    

提交回复
热议问题