Organizing Stan plots

Hi all,
First, thanks for all of your help so far. I know I have been asking lots of questions. My next question concerns organizing Stan plots. For context, I’m writing a document using RStudio, LaTeX, knitr, and Markdown. Everything compiles fine and I am getting various Stan plots, but they are very large on the page. I was hoping to have them in two rows of two. The commands are

stanplot <- stan_plot(myfit, pars=c(“alpha”,“beta1”,“sigma”))
stantrace <- stan_trace(myfit,inc_warmup=T, pars=c(“alpha”,“beta1”,“sigma”))
standens <- stan_dens(myfit, pars=c(“alpha”,“beta1”,“sigma”))
stanac <- stan_ac(myfit, pars=c(“alpha”,“beta1”,“sigma”))

I’ve tried grid.arrange and also par(2,2) to no avail. Any hints on how to arrange these plots would be great.

Thanks

David

I’m pretty sure they’re just ggplot2 objects, so you should be able to use packages like gridExtra, cowplot, etc to arrange them. See here for a vignette on the ecosystem of ggplot2 arrangers.

I strongly recommend using patchwork for organizing your plots:

Makes it super easy to align plots, i.e., in your case you’d use,

(stanplot + stantrace) / (standens + stanac)