two graphs on one page

hi, what is the code to combine two graphs to one page for pdf output? i tried fig.dim = c(8, 6)but it is not working. may i pls be guided to it? thank you!

i do not mind adjusting the sizes of the graphs. thanks!

Use the {patchwork} package to combine

do i insert a separate chunk for it or enter it as is? thank you!

In the chunk, create p1 and p2, then p1 + p2 for side-by-side, or p1/p2 for top/bottom, using ggplot2 to create p1 and p2

1 Like

hi does it work until p9? because i tried p7+p8/p9 and it says its nonnumeric.

My guess is that the error is for one of the plots, not from {patchwork}.


p <- ggplot(mtcars,aes(mpg,drat))
p1 <- p + geom_point()
p2 <- p + geom_line()
p1 + p2

p1 / p2

ok will work on this. thank you!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.