Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use custom point style in plot?

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.

enter image description here

like image 550
ziyuang Avatar asked Dec 05 '12 01:12

ziyuang


1 Answers

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):

enter image description here

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.

enter image description here

like image 56
thelatemail Avatar answered Nov 05 '22 02:11

thelatemail