[R] i need help about reverse axes

From: Ali Alsamawi <ali.alsamawi_at_unsw.edu.au>
Date: Fri, 04 Jun 2010 10:48:02 +1000

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



R-help_at_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.
Rplot001.png
Received on Fri 04 Jun 2010 - 04:11:37 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 04 Jun 2010 - 14:40:27 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive