Hi,

I have been trying to output my graphs to a file (jpeg, pdf, ps, it doesnt matter) but i cant seem to be able to get it to output. I tried a few things but none of them worked and am lost as what to do now. I am using the scatter3d function, and it prints out the graphs on tot he screen without any problems, but when it comes to writing them to a file i cant make it work. Is there any other way of producing 3dimensional graphs (they dont have to be rotatable/interactive after the print out)?

The code is fairly simple and is listed down :

#libraries
library(RMySQL)
library(rgl)
library(scatterplot3d)
library(Rcmdr)

##############################################################################
#database connection
mycon <- dbConnect(MySQL(), user='root',dbname='test',host='localhost',password='')
#distinct sessions
rsSessionsU01 <- dbSendQuery(mycon, "select distinct sessionID from actiontimes where userID = 'ID01'")
sessionU01 <-fetch(rsSessionsU01)
sessionU01[2,]

#user01 data
mycon <- dbConnect(MySQL(), user='root',dbname='test',host='localhost',password='') rsUser01 <- dbSendQuery(mycon, "select a.userID,a.sessionID,a.actionTaken,a.timelineMSEC,a.durationMSEC,b.X,b.Y,b.Rel__dist_,b.Total_dist_ from `actiontimes` as a , `ulogdata` as b where a.originalRECNO = b.RECNO and a.userID='ID01'")
user01 <- fetch(rsUser01, n= -1)
user01[1,1]

#plot loop

for (i in 1:10){

userSubset<-subset(user01,sessionID == sessionU01[i,],select=c(timelineMSEC,X,Y))
    userSubset
    x<-as.numeric(userSubset$X)
    y<-as.numeric(userSubset$Y)
scatter3d(x,y,userSubset$timeline,xlim = c(0,1280), ylim = c(0,1024), zlim=c(0,1800000),type="h",main=sessionU01[i,],sub=sessionU01[i,])
    tmp6=rep(".ps")
    tmp7=paste(sessionU01[i,],tmp6,sep="")
    tmp7
    rgl.postscript(tmp7,"ps",drawText=FALSE)
    #pdf(file=tmp7)
    #dev.print(file=tmp7, device=pdf, width=600)
    #dev.off(2)
}

______________________________________________
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