I have 3 R plots saved as pdf files (upper_left.pdf
, upper_right.pdf
, lower.pdf
) as vector graphic and want to make a one-page pdf file and arrange them on it as follows:
What I have tried already
I have tried reading the pdf's using magick::image_read_pdf
and appending them using magick::image_append
. More specifically,
library(magick)
panel.ul <- image_read_pdf("upper_left.pdf")
panel.ur <- image_read_pdf("upper_right.pdf")
panel.l <- image_read_pdf("lower.pdf")
whole <- c(panel.ul, panel.ur) %>%
image_append() %>%
c(panel.l) %>%
image_append(stack = TRUE)
The first issue is magick::image_read_pdf
imports the plot as png
(if I'm right, not vector graphic though).
magick::image_append
also 'works' and gives me what I want in viewer
pane (in RStudio, next to Help
).
I then try to save them using export::graph2pdf(whole)
, but it gives me a blank page.
So, if I am to use magick
, there are two issues that need to be solved:
- importing plots as vector graphic objects (do not know the technical term in R)
- Exporting the stacked plot to a vector pdf file.
How can I solve it? thanks in advance.