Marlin Keith Cox said the following on 2/15/2008 11:39 AM: > Dear R Users, close to the end of this I used wireframe to create a 3D plot > from a matrix. The x and y axis tick labels (1-6) for each were created > from the matrix being a 6X6 matrix. I need the axis tick labels to be the > row and column headings which you can see in the output (mat.x). I have > tried several work arounds, but they have not been successful. > > Thanks in advance. keith > > > rm(list=ls()) > sen<-read.csv("brooktroutsort.csv") > > #Resistance > R=c(660, 548, 676, 763, 768, 692, 657, 630, 748, 680, 786, 645, 710, 677, > 692, 732, 737, 651, 396, > 601, 640, 448, 464, 472, 434, 487, 495, 426, 429, 456) > > #Detector length > Lend=c(37.0, 39.0, 39.0, 39.0, 40.0, 41.5, 44.0, 45.0, 46.0, 47.0, > 47.0, 48.0, > 48.5, 49.0, 51.0, 53.0, 53.0, 60.0, 89.0, 103.0, 108.5, 118.0, 118.0, > 123.0, > 126.0, 138.0, 139.0, 141.0, 141.0, 151.0) > > #Errors to be multiplied by Restistance > x=c(0,.05,.10,.15,.20,.25) > > #Errors to be multiplied by Detector length > y=c(0,.01,.02,.03,.04,.05) > > #equation to predict water weight in grams > a=3.453*((Lend^2)/R)+1.994 > > X=(R%o%x+R) > > Y=((Lend%o%y+Lend)^2) > > num.x.col <- length(X[1,]) > num.y.col <- length(Y[1,]) > num.rows <- length(X[,1]) > > Z <- matrix(nrow=num.rows, ncol=num.x.col*num.y.col) > > for( i in 1:num.rows) { > Z[i,] <- as.vector( Y[i,] %*% t(X[i,])^-1 ) > } > > pred.est <- 3.453*Z+1.994 > z=(pred.est-a)/a > > colnames(z)<- rep(c("X1","X2","X3","X4","X5","X6"),6) > > meanz=colMeans(z) > mat.x <- matrix(meanz, nrow=6, ncol=6, byrow=TRUE) > > colnames(mat.x)<- c(0,1,2,3,4,5) > rownames(mat.x)<-c(0,5,10,15,20,25) > mat.x > > > library(lattice) > wireframe(mat.x,drape=TRUE,zlab=list("Proportion Error of Estimate", > rot=90), xlab="Resistance Error (%) ",ylab="Length Error > (%)",scale=list(arrows=FALSE)) > detach(z) > detach(sen) > >
Try: mat.df <- data.frame(z = as.vector(mat.x)) mat.df$x <- rep(c(0,5,10,15,20,25), each = 6) mat.df$y <- rep(c(0,1,2,3,4,5), times = 6) library(lattice) wireframe(z ~ x * y, mat.df, drape = TRUE, zlab = list("Proportion Error of Estimate", rot=90), xlab = "Resistance Error (%) ", ylab = "Length Error (%)", scales = list(arrows = FALSE)) HTH, --sundar ______________________________________________ R-help@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.