[R] plotting on an image

Greg Snow Greg.Snow at imail.org
Wed Jun 15 00:03:50 CEST 2011


If you are willing to prepend a step then you could:

1. Create an empty plot using your data and type='n' (or just plot the data, the points will be overwritten), you may want to set the asp argument, or explicitly do the xlim and ylim arguments.
2. Add the graphic using the rasterImage function
3. Use functions such as points or lines (or others that add to existing plots) to plot you data on top of the image.

If you need certain points within the image to correspond to certain coordinates then the locator and updateusr (TeachingDemos package) may be of help.

But in all of this, make sure that you really want to do this, often (but not always) putting an image in the background is chartjunk that distracts more than helps.

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at imail.org
801.408.8111


> -----Original Message-----
> From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-
> project.org] On Behalf Of Johann Kim
> Sent: Monday, June 13, 2011 12:33 PM
> To: r-help at r-project.org
> Subject: [R] plotting on an image
> 
> Hello all,
> 
> has someone please a few hints about how to
> 1.st: draw an image (preferrably a jpg) and then
> 2nd: plot() on that image
> 
> I am using a mac - and after searching and trying  different ways (I
> have installed EBImage) I now would like to ask for help...
> 
> Thanks!
> Johann
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list