[R] add colors to persp plot to reflect levels of z values

Yuandan Zhang yzhang4 at une.edu.au
Tue Oct 10 02:11:54 CEST 2006


Hi, 
I try to use persp to draw perspective plots of surfaces in a region.
the data matrix is 606x354
here is my simple code:

r<-read.table (file='prod.asc.txt', header=F)
r[r==-9999]<-NA   # no values in surrounding region
r<-as.matrix(r)
y<-seq(1:ncol(r)) #354 cols
x<-seq(1:nrow(r)) #606 rows
png (file="prod.png")
persp(x,y, r, theta = 100,  phi = 30, expand=0.5, col =10, ltheta=120,
shade = 0.75, ticktype='detailed', d=.4, lty=0, border=NULL)
dev.off()

as the data points are very dense, i set the lty to 0. r ranges from 200
to 600.

I want to add a series of colors (say 10) to reflect the levels (eg 10)
of r values. how to do this? 
 
regards,
-- 
Yuandan



More information about the R-help mailing list