[R] graphs superimposed on pictures?

Greg Snow Greg.Snow at intermountainmail.org
Wed Apr 11 17:58:44 CEST 2007


Here are some examples that may be what you are looking for:

library(rimage)
x <- read.jpeg(system.file("data", "cat.jpg", package="rimage"))
plot(x)
par(new=TRUE)
plot( runif(100), rnorm(100), col='green' )

x2 <- x/4 + 3/4
plot(x2)
locator() # click on corners to get extent of picture
library(TeachingDemos)
subplot( fun=plot(runif(100), rnorm(100)), x=c(-1.26, 416.65), 
   y=c(0.1744, 421.57) )

library(maptools)
plot(state.vbm, xlim=c(0,55), ylim=c(20,60))
tmp <- structure(list(x = c(16, 20, 32, 46, 32, 45), y = c(39, 54, 52, 
51, 34, 34)), .Names = c("x", "y")) # from locator()
states <- c('California','Nevada','Utah','Colorado','Arizona','New
Mexico')

data(Teacher, package='BSDA')

for (s in states){
	i <- which(Teacher$State == s)
	j <- which(states==s)
	subplot( plot( c(73, 83, 93), Teacher[i,-1],
type='b',xlab='',ylab='' ), 
		tmp$x[j], tmp$y[j], size=c(.5,.5))
}


Hope this helps,

-- 
Gregory (Greg) L. Snow Ph.D.
Statistical Data Center
Intermountain Healthcare
greg.snow at intermountainmail.org
(801) 408-8111
 
 

> -----Original Message-----
> From: r-help-bounces at stat.math.ethz.ch 
> [mailto:r-help-bounces at stat.math.ethz.ch] On Behalf Of Robert Biddle
> Sent: Wednesday, April 11, 2007 7:40 AM
> To: r-help at stat.math.ethz.ch
> Subject: [R] graphs superimposed on pictures?
> 
> Hi:
> 
> I am doing some work that involves plotting points of 
> interest superimposed on photographs and maps. I can produce 
> the plots fine in R, but so far I have had to do the 
> superimposition externally, which makes it tedious to do 
> exploratory work.
> I have looked to see if there is some capability to put a 
> background picture on a plot window, but I have not found anything.
> Advice, anyone?
> 
> Cheers
> Robert Biddle
> 
> ______________________________________________
> 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
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list