Skip to content
Prev 132037 / 398506 Next

Overlaying trellis xyplot on contourplot

Hi Seth,

An alternative would be to use ggplot2, http://had.co.nz/ggplot2:

model <- function(a,b,c,X1,X2)  {
  (exp(a + b*X1 + c*X2)) / (1 + exp(a + b*X1 + c*X2))
}

g <- expand.grid(X1 = seq(0.40, 0.8,0.01), X2 = seq(0.03,0.99,0.03))
a <- -37.61
b <- 34.88
c <- 28.44
g$z<- model(a, b, c, g$X1,g$X2)

ph <-c(0.42,0.47,0.59,0.40)
phh <-c(0.76,0.81,0.82,0.71)
d <- data.frame(ph,phh)

library(ggplot2)
qplot(X1, X2, data = g, fill = z, geom="tile", xlab="p(H)", ylab="p(H|H)")+
 geom_contour(aes(z=z)) +
 geom_point(aes(x = ph, y = phh, fill = NULL), data=d)

Plots in ggplot2 have multiple layers which can have different data sources.

Hadley
On 12/13/07, Seth W Bigelow <sbigelow at fs.fed.us> wrote: