### GENERATE DATA inv.logit <- function(x){exp(x)/(1+exp(x))} Weight <- seq(10,80, by=2) Dose <- seq(0,1, by=.02) z <- matrix(NA, length(Weight), length(Dose)) for(i in 1:length(Weight)){ for(j in 1:length(Dose)){ z[i,j] <- inv.logit(-3*( Dose[j] - ((Weight[i]+20)/100) )^2 + Dose[j] - Weight[i]/100) # + rnorm(1,0,.03)) } } Survival <- z persp(Weight, Dose, Survival, phi=45, theta=35) ### Colors nrz <- nrow(z) ncz <- ncol(z) # Create a function interpolating colors in the range of specified colors jet.colors <- colorRampPalette( c("blue", "green") ) # Generate the desired number of colors from this palette nbcol <- 100 color <- jet.colors(nbcol) # Compute the z-value at the facet centres zfacet <- z[-1, -1] + z[-1, -ncz] + z[-nrz, -1] + z[-nrz, -ncz] # Recode facet z-values into color indices facetcol <- cut(zfacet, nbcol) ### PLOTS: pdf("Figure1.pdf",width=8,height=8) surf.plot <- persp(Weight, Dose, Survival, col = color[facetcol], phi = 30, theta = 35, zlim=c(0,.7), ltheta = 120, shade = 0.25, ticktype = "detailed") dev.off() pdf("Figure1a.pdf",width=6,height=6) surf.plot <- persp(Weight, Dose, Survival, col = color[facetcol], phi = 30, theta = 35, zlim=c(0,.7), ltheta = 120, shade = 0.25, ticktype = "detailed") lines(trans3d(c(20,20), c(0,1), c(.6,.6),surf.plot),col="red", lwd=4) lines(trans3d(c(20,20), c(0,0), c(0,.6),surf.plot),col="red", lwd=4) dev.off() pdf("Figure1b.pdf",width=5,height=5) plot(Dose, Survival[which(Weight==20),], type="l", xlab="Dose", ylab="Survival", col="red", ylim=c(.1,.6)) abline(v=Dose[which.max(Survival[which(Weight==20),])], lty=3) text(0.2,0.35, labels="Weight = 20") dev.off() pdf("Figure1c.pdf",width=5,height=5) plot(Dose, Survival[which(Weight==60),], type="l", xlab="Dose", ylab="Survival", col="blue", ylim=c(.1,.6)) abline(v=Dose[which.max(Survival[which(Weight==60),])], lty=3) text(0.2,0.35, labels="Weight = 60") dev.off()