I want to display multiple ggplot
objects in one figure using package gridExtra
. It works, but titles are cut. I can fix it by changing plots font size, but I would rather change the width of the whole figure so that it is wide enough to fit in titles (and as wide as other outputs in my RMarkdown doc, e.g. the table right over it). I've tried to change margins by typing par(mai = 2*par('mai'))
before call to grid.arrange
, but it did nothing. Does anyone know how to do it properly? I am really confused about the gridExtra
package.
library(gridExtra)
g <- grid.arrange(zad4_kl$pw, zad4_kl$pk, zad4_kl$pp, zad4_AC$pw, zad4_AC$pk, zad4_AC$pp, nrow = 2)
g
If you are saving the image, then you can increase the width and dpi in
ggsave
.In R Markdown, you can use
fig.width
andfig.height
If rendered image doesn't fit the Markdown output, then you will have to change font in individual plots.