I have a set of data in the form x1, y1, z1 x1, y2, z2 ... x1, yN, zN x2, y1, z(N+1) x2, y2, z(N+2) ... x2, yN, z(2N) ...and so on... xM, yN, val(M*N)
I have been trying to figure out how to get R to use this data in a persp plot. So far the only thing that I can figure out to do is to break the data file into three different files. The first file contains the x-coordinate data: x1 x2 ... xM The second file contains the data y1 y2 ... yN And finally the last file contains the data for the z-axis. z1 z2 ... z(M*N) Once I have the three data files created I use them in the following R script: cat << EOF | R --no-save def.par <- par(no.readonly = TRUE) en_range <- c(-6.2, 0.0) om_range <- c(-200.0, 500.0) ze_range <- c(0.0, 1.0) z_perspective <-c(0,3) xdata <- scan("x.txt", list(0)) ydata <- scan("y.txt", list(0)) zdata <- scan("z.txt", list(0)) f <- function(xdata,ydata) { rr <- zdata; rr } z <- outer(xdata, ydata, f) pdf(file="persp.pdf",height = 8, width =8) persp(xdata, ydata, z, axes = TRUE, nticks = 5, ticktype = "detailed",r=1.5) dev.off() q() EOF The problem is that when I look at the plot, the peaks of the zdata are i The problem is that when I look at the plot, the peaks of the zdata are in the wrong places on the x axis. I have carefully looked over my data files and I am confident that they are correct. Thus I believe that the error is in my R script; most likely in the following lines f <- function(xdata,ydata) { rr <- zdata; rr } z <- outer(xdata, ydata, f) Do you have any suggestions? Chad Junkermeier, Graduate Student Dept. of Physics West Virginia University PO Box 6315 210 Hodges Hall Morgantown WV 26506-6315 ----------------------------------------------------- Concurrently at: Dept. of Physics and Astronomy Brigham Young University Provo UT 84602 [[alternative HTML version deleted]] ______________________________________________ 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.