scatterplot3d() currently does not supoort it, but you can hack an ugly workaround:

If you want to do it only once ot twice:

mirror your z data at mean(range of z axis) and add z.ticklabs manually (the reverse numbers)

Example:

x <- 1:10
y <- 1:10
z <- 1:10
s3d <- scatterplot3d(x, y, z)
env <- environment(s3d[[1]])
zmin <- get("z.min", env=env) * get("z.scal", env=env)
zmax <- get("z.max", env=env) * get("z.scal", env=env)
zmean <- mean(c(zmin, zmax))
znew <- 2*zmean - z
scatterplot3d(x, y, znew, z.ticklabs=rev(get("z.prty", env=env)))

Best,
Uwe Ligges











Am 04.06.2010 02:48, schrieb Ali Alsamawi:

Hello

      im trying to plot 3d  with scatterplot packages , everything is work on my program 
below  but my problenm i want to set my pressure level or axis(z-axis) to reverse like 
from bottom to top, i used function "rev" but not work just for 2d plots the 
figure in attachment and the program shows below, can anyone help me to do this


Thanks
Ali




##load rgl package
library()
library(scatterplot3d)


## open binary file to read
dat<- file("/srv/scratch/z3303149/back_Traj/parcel1_1",open="rb")
skip1st1 = seek(dat,where=4)
alldata = readBin(dat,numeric(),n=5040,size=4)
dim(alldata)<- c(10,504)

totlen= 504
## replace zeros in lon,lat,pres,wv_cont with missing
for (i in 1:totlen) {
   if (alldata[2,i]==0) alldata[2,i] = NA
   if (alldata[3,i]==0) alldata[3,i] = NA
   if (alldata[4,i]==0) alldata[4,i] = NA
   if (alldata[10,i]==0) alldata[10,i] = NA
}

## total number of non-missing values
len = totlen - sum(is.na(alldata[2,]))



## set the dataset to use for colouring
coldat = alldata[10,1:len]

## creat colour from wv_cont - in hsv
hcol = cumsum(coldat)

hcol = hcol/max(hcol,na.rm=TRUE)
print(hcol)
col<- hsv(h=hcol,s=1,v=1)






X<- scatterplot3d(alldata[2,1:len],alldata[3,1:len],alldata[4,1:len],
xlab="lon",ylab="lat",zlab="pres",main="The Trajectory of the parcel1_1 
(%)",zlim=rev(range(alldata[4,1:len])))

#to show the first point of the trajectory
X$points3d(alldata[2,1],alldata[3,1],alldata[4,1],col =col, type = "p", pch = 
15)

X$points3d(alldata[2,1:len],alldata[3,1:len],alldata[4,1:len],col =col, type = 
"p", pch = 1)


## create labelbar - need to create an image in order to do so
lbcol = hsv(h=seq(0,1,0.01),s=1,v=1)
tmp1=c(1:len)
tmp3=matrix(coldat,len,1)




par(oma=c( 0,0,0,0),font.axis=1,mar=(c(14.1,4.1,4.1,1.1)),cex=0.8)
image.plot(tmp1,1,tmp3,add=TRUE,legend.only=TRUE,col=lbcol,nlevel=10
,legend.shrink=0.8,legend.width=1)





#png()





Rplot001.png




______________________________________________
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.

______________________________________________
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.

Reply via email to