[R] i need help about reverse axes

Ali Alsamawi ali.alsamawi at unsw.edu.au
Fri Jun 4 02:48:02 CEST 2010


     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


##load rgl package

## 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)
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)

par(oma=c( 0,0,0,0),font.axis=1,mar=(c(14.1,4.1,4.1,1.1)),cex=0.8)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: Rplot001.png
Type: image/png
Size: 7225 bytes
Desc: Rplot001.png
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20100604/bd4c6b16/attachment.png>

More information about the R-help mailing list