Вопрос по ggplot2, r – Как мне организовать переменный список графиков, используя grid.arrange?

61
library(ggplot2)
df <- data.frame(x=1:10, y=rnorm(10))
p1 <- ggplot(df, aes(x,y)) + geom_point()
plist <- list(p1,p1,p1,p1,p1)
# In my real example,a plot function will fit a ggplot to a list of datasets 
#and return a list of ggplots like the example above.

Error: User Rate Limit Exceededgrid.arrange()Error: User Rate Limit ExceededgridExtra.

Error: User Rate Limit ExceededplistError: User Rate Limit Exceeded

Error: User Rate Limit Exceededgrid.arrange(plist[[1]],plist[[2]],plist[[3]],plist[[4]],plist[[5]])

Error: User Rate Limit Exceeded

Error: User Rate Limit Exceeded?grid.arrange baptiste

Ваш Ответ

5   ответов
10

cowplot

cowplot::plot_grid(plotlist = plist, ncol = 2)

enter image description here

ggplot2. grid.arrangeError: User Rate Limit Exceededstackoverflow.com/questions/43216262/…Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededpatchwork::wrap_plots.
Error: User Rate Limit ExceededError in ggplot_to_gtable(x) : Argument needs to be of class "ggplot" or "gtable"
Error: User Rate Limit Exceededggplot2Error: User Rate Limit Exceeded
16

grid.arrange()arrangeGrob()grobs =

library(ggplot2)
library(gridExtra)
df <- data.frame(x=1:10, y=rnorm(10))
p1 <- ggplot(df, aes(x,y)) + geom_point()
plist <- list(p1,p1,p1,p1,p1)

grid.arrange(grobs = plist, ncol = 2) ## display plot
ggsave(file = OutFileName, arrangeGrob(grobs = plist, ncol = 2))  ## save plot
Error: User Rate Limit Exceeded
4

gridExtrawrap_plotspatchwork

library(ggplot2)
# devtools::install_github("thomasp85/patchwork")
library(patchwork)

df <- data.frame(x=1:10, y=rnorm(10))
p1 <- ggplot(df, aes(x,y)) + geom_point()
plist <- list(p1,p1,p1,p1,p1)

wrap_plots(plist)

enter image description here

plist <- list(p1,p1,p1,p1,p1,p1,p1,p1,p1,p1,p1,p1,p1)
wrap_plots(plist) # produces a 4 col x 4 row plot

Find out more about the patchwork package here

Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededdevtools::install_github("thomasp,85/patchwork")?
1

x = length(plots)

cols = round(sqrt(x),0)
rows = ceiling(x/cols)

ggarrange(plotlist = plots, ncol=cols, nrow = rows)

96

library(gridExtra)
n <- length(plist)
nCol <- floor(sqrt(n))
do.call("grid.arrange", c(plist, ncol=nCol))

enter image description here

Error: User Rate Limit Exceededx <- list(1,2); x[[3:1]]Error: User Rate Limit Exceededplist[...]Error: User Rate Limit Exceededplist[[...]]Error: User Rate Limit Exceededdo.call()Error: User Rate Limit Exceededgrid.arrange()Error: User Rate Limit Exceeded
Error: User Rate Limit Exceededgrid.arrange(plist[[1:length(plist)]], ncol = nCol))Error: User Rate Limit ExceededError in hl.plots[[1:12]] : no such index at level 3Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded

Похожие вопросы