[R] Plotting using image files

Greg Snow greg.snow at ihc.com
Tue Aug 23 16:59:04 CEST 2005


>>> "Mike Saunders" <mike_saunders at umenfa.maine.edu> 08/23/05 06:52AM
>>>
>> This is a strange request, but I want to build a scatterplot using
different image files (jpegs, gif, etc.) as the plot symbols.
>>   I have thought about setting this up using a very large layout
matrix, but I thought someone might have a better
>>  approach.  Furthermore, is there any way to have R paste an image
file into a specific coordinate within a scatterplot?

Here is an example using cnvrt.coords from the TeachingDemos package
and the jpeg plotting functions from the rimage
package:

library(TeachingDemos)
library(rimage)
data(logo)

x <- runif(10,3,6)
y <- runif(10,100,200)

plot(x,y, type='n')

cp <- par(no.readonly=TRUE)
tmp <- cnvrt.coords(x,y)

for (i in 1:10){
  par(plt=c(tmp$dev$x[i] + c(-0.03,0.03), tmp$dev$y[i] +
c(-0.03,0.03)),
      new=TRUE)
  plot(logo)
}

par(cp)


hope this helps,

Greg Snow, Ph.D.
Statistical Data Center, LDS Hospital
Intermountain Health Care
greg.snow at ihc.com
(801) 408-8111




More information about the R-help mailing list