I\'m trying to add a picture (jpeg,png doesn\'t care) to a plot which is defined by the layout function. For example:
a<-c(1,2,3,4,5)
b<-c(2,4,8,16,32
Just wanted to offer an alternative solution from the builtin "grid" package called grid.raster
From what I can tell it acts very much like rasterImage, but takes in normalized units, "npc" --a bonus in my opinion, and preserves aspect ratio unless you set both width and height. For my purposes, i just set either/or and the image seems to scale perfectly.
library(png)
library(grid)
x11()
mypng = readPNG('homer.png')
image(volcano)
grid.raster(mypng, x=.3, y=.3, width=.25) # print homer in ll conrner
grid.raster(mypng, x=.9, y=.7, width=.5) # print bigger homer in ur corner
while(!is.null(dev.list())) Sys.sleep(1)
