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? Thanks in advance, Mike Mike Saunders Research Assistant Forest Ecosystem Research Program Department of Forest Ecosystem Sciences University of Maine Orono, ME 04469 207-581-2763 (O) 207-581-4257 (F) [[alternative HTML version deleted]]
Mike Saunders wrote:> 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?I don't think this is possible using the default graphics engine in R, but here is another solution using ImageMagick (http://www.imagemagick.org/) calls from R. I once needed something similar to highlight certain cities on a Swedish map given their longitute/latitude coordinates. The map was given as bitmap image. Given a few reference citites with known longitute/latitude and pixel coordinates I used a quick-and-dirty 2d-loess to get a longitute/latitude-to-pixel coordinate mapping. This way I could find the pixel coordinates for new citites and then I used ImageMagick to add colorful discs in the original bitmap image. The result is as shown on http://www.maths.lth.se/kovalevsky/skolor/. It is quite easy to write wrapper functions in R that calls ImageMagick via system() calls. My code is in http://www.maths.lth.se/kovalevsky/skolor/updatemap.R, but please don't ask me to explain how it works, because I don't have the time available for that. Basically, ImageMagick's 'convert' command provide command line options to add discs ("circles"), lines etc in different colors to existing images. Make sure to set a pen color before drawing. I think it allows you to "draw" using other bitmap image too. My R code generates a convert call string which is called at the end. Hope this helps a bit Henrik Bengtsson> Thanks in advance, > Mike > > > Mike Saunders > Research Assistant > Forest Ecosystem Research Program > Department of Forest Ecosystem Sciences > University of Maine > Orono, ME 04469 > 207-581-2763 (O) > 207-581-4257 (F) > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html > >
Le 23.08.2005 14:52, Mike Saunders a ??crit :>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? > >Thanks in advance, >Mike > > >Hello Mike, Maybe you can try using the pixmap package, something like this : require(pixmap) logo <- read.pnm(system.file("pictures/logo.ppm", package="pixmap")[1]) x <- rnorm(10) y <- rnorm(10,sd=.4)+x plot(x,y, type="n") for(i in 1:10){ u <- runif(1)/10 + .1 addlogo(logo, x[i]+c(-u,u), y[i]+c(-u,u), asp=1) } # points(x,y, pch="+") All you have to de then is having your images in ppm format. I think gimp will do it for you. There is also a few tools in netpbm (only on linux i think). Romain -- visit the R Graph Gallery : http://addictedtor.free.fr/graphiques ~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~ ~~~~~~ Romain FRANCOIS - http://addictedtor.free.fr ~~~~~~ ~~~~ Etudiant ISUP - CS3 - Industrie et Services ~~~~ ~~ http://www.isup.cicrp.jussieu.fr/ ~~ ~~~~ Stagiaire INRIA Futurs - Equipe SELECT ~~~~ ~~~~~~ http://www.inria.fr/recherche/equipes/select.fr.html ~~~~~~ ~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~
>>> "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 usingdifferent image files (jpegs, gif, etc.) as the plot symbols.>> I have thought about setting this up using a very large layoutmatrix, but I thought someone might have a better>> approach. Furthermore, is there any way to have R paste an imagefile 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