xy <- data.frame(x=runif(10, 0, 100), y=runif(10, 0, 100))
require(png)
img <- readPNG(system.file("img", "Rlogo.png", package="png"))
thumbnails <- function(x, y, images, width = 0.1*diff(range(x)),
height = 0.1*diff(range(y))){
images <- replicate(length(x), images, simplify=FALSE)
stopifnot(length(x) == length(y))
for (ii in seq_along(x)){
rasterImage(images[[ii]], xleft=x[ii] - 0.5*width,
ybottom= y[ii] - 0.5*height,
xright=x[ii] + 0.5*width,
ytop= y[ii] + 0.5*height, interpolate=FALSE)
}
}
plot(xy, t="n")
thumbnails(xy[,1], xy[,2], img)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…