datetime - Rotated x labels in R -


i have data in r following:

   bag_id location_type            event_ts 1     155      transfer 2012-01-02 15:57:54 2     155        sorter 2012-01-02 17:06:05 3     305       arrival 2012-01-01 07:20:16 4     692       arrival 2012-03-29 09:47:52 10    748      transfer 2012-01-08 17:26:02 11    748        sorter 2012-01-08 17:30:02 12    993       arrival 2012-01-23 08:58:54 13   1019       arrival 2012-01-09 07:17:02 14   1019        sorter 2012-01-09 07:33:15 15   1154      transfer 2012-01-12 21:07:50 

where class(event_ts) "posixct".

i wanted find density of bags @ each location in different times. so, used function density following:

    adj<-.00001     dsorter<-density(as.numeric(data$event_ts[which(data$location_type=="sorter")]),n=length(data$event_ts[which(data$location_type=="sorter")]),adjust = adj)      starttime<-as.posixct(strptime("2012-06-01", "%y-%m-%d"), tz="utc") # want zoom & see part of data     endtime<-as.posixct(strptime("2012-06-3", "%y-%m-%d"), tz="utc")     range<-range(as.numeric(c(starttime,endtime)))     lablist.x<-substr(seq(starttime,endtime,by="hour"),start=6, stop=13) # want have time labels plot     plot(dsorter, main="sorter",xlim=range, xaxt = "n")     axis(1, at=as.numeric(seq(starttime,endtime,by="hour")), labels =f) text(1:49,par("usr")[3] - 0.25, labels=lablist.x,srt = 45,adj=1, , xpd = true) #want rotate labels 

the last comment not work , not know how should recognize "x" values @ function "text".

thank in advance kind of comments , guidance.

best, shima.

the problem solved, found coordinates have use in function "text" command: par("usr") , changed last line of code following:

text(c(as.numeric(seq(starttime,endtime,by="hour"))),par("usr")[3]-(par("usr")[4]-par("usr")[3])/20,  labels=lablist.x,srt = 45,adj=1,  xpd = true) 

Comments

Popular posts from this blog

plot - Remove Objects from Legend When You Have Also Used Fit, Matlab -

java - Why does my date parsing return a weird date? -

Need help in packaging app using TideSDK on Windows -