Reputation: 4558
I am doing a dimensional reduction experiment, where a set of faces will be places onto a X-Y plane. I want to show the real face at each point in the plot (Example: Figure 10 at the page 476). Can I do this in R? Thank you.
Upvotes: 9
Views: 1665
Reputation: 93813
You will probably need some add-on packages like png
and raster
to achieve this.
So first up, make sure you have the packages loaded.
library(png)
library(raster)
Now, get an image (an awesome squiggle I made in ms paint - saved as spotimg.png
):
Load the image into R and plot it:
pngimg <- readPNG("spotimg.png")
plot(NA,xlim=c(0,10),ylim=c(0,10))
rasterImage(pngimg,4.5,4.5,5,5)
The last 4 inputs to the rasterImage
call give the coordinates of the image's boundary in the format xleft, ybottom, xright, ytop
And bingo, there's your image plotted where you specified.
Upvotes: 8