-2

I would like to add jpeg picture in a place of 'ao' in the following figure

library(ggplot2)
da <- data.frame(x = seq(0, 100, 1), y = seq(0, 1, 0.01))
ao <- ggplot()
a1 <- ggplot(aes(x = x, y = y), data = da) + geom_line()
a2 <- ggplot(aes(x = x, y = y), data = da) + geom_point()
a3 <- ggplot(aes(x = x, y = y), data = da) + geom_line(lty = 2)

library(cowplot)
plot_grid(ao, a1, a2, a3, labels=c("a)", "c)", "b)", "d)"), ncol = 2, nrow = 2)

I am not restricted to ´cowplot´ library. anything that works is fine.

Mateusz1981
  • 1,817
  • 17
  • 33
  • `a0` doesn't apear in your code. `ao` does, though. What have you tried so far, and why didn't it work? – Limey Sep 22 '22 at 07:28

1 Answers1

-2

Ok, I finally solved it like that

library(ggplot2)
    ao <- ggplot()
    image <- load.image("FIGURE/xxxx.png")
    library(magick)
    
    a0 <- ggdraw(a0) + draw_image(image)


da <- data.frame(x = seq(0, 100, 1), y = seq(0, 1, 0.01))

a1 <- ggplot(aes(x = x, y = y), data = da) + geom_line()
a2 <- ggplot(aes(x = x, y = y), data = da) + geom_point()
a3 <- ggplot(aes(x = x, y = y), data = da) + geom_line(lty = 2)

library(cowplot)
plot_grid(ao, a1, a2, a3, labels=c("a)", "c)", "b)", "d)"), ncol = 2, nrow = 2)
Mateusz1981
  • 1,817
  • 17
  • 33