Hi, I am plotting data in which the x values are a timestamp. I am trying to change the x-ticks so they will be in specified hours of the day, but it always start from hour 4 of the day. And I need it to start from the beginning of the axis (at x=0) and then each tick be on the interval I specify.
Here is my plotting script: *##-- ROOF COMPARISON - SOUTH-- win.graph() plot(x=tiempo,y=timeframe[,8],xlab="",ylab="",**xaxt='n',** yaxt='n',type="l",col="blue",lwd=3,ylim=c(0,80),font=2,las=1) axis(side=1,at=seq(0,24,3)) axis(side=2,at=seq(0,80,10),line=NA, tcl = -0.5,font=2,las=1) lines(x=tiempo,y=timeframe[,47],col="red",lwd=3) title(xlab=paste("Local Standard Time (",date), cex.lab=1,font.lab=2) title(ylab="Temperature (°C)", cex.lab=1,font.lab=2) legend("topleft",legend=c("cool", "standard"),col=c("blue", "red"),lwd=c(4,4),bty="n",cex=1.25) grid(nx=NULL,ny=NULL,col = "gray", lty = "dotted",lwd = 1)* But with the axis(side=1...) nothing appears. I have been practicing with the following code to change the xaxis but it says that x and y lengths differ: *## TIMESTAMP IS A ONE COLUMN VECTOR IN WHICH I SAVED THE TIMESTAMP FROM MY FILE string.to.time <- function(timestamp) strptime(x=timestamp, format="%Y-%m-%d %H:%M:%S") decimal.day <- function(timestamp) { y <- as.POSIXlt(**timestamp**) y$day + y$hour/24 + y$min/(24*60) + y$sec/(24*60*60) } decimal.hour <- function(**timestamp**) { dd <- decimal.day(**timestamp**) 24 * (dd - floor(dd)) } ##create some data to plot t.start <- string.to.time("2011-05-02 00:00:00") t.start t.vector <- t.start + (0:24)*3600 t.vector z.vector <- 1:length(t.vector) z.vector ##vector of decimal hours dh.vector <- decimal.hour(t.vector) dh.vector plot(x=dh.vector, y=z.vector, xlim=c(0,24), xaxt="n", xlab="Hour of day", ylab="Some property") * Thank You so much and have a great weekend. -- *Pablo J. Rosado*, *Ph.D. Student* *Graduate Student Researcher Assistant* *University of California - Berkeley* *Lawrence Berkeley National* *Lab** *||* *EET Division* *|| *Heat Island Group Office (510) 495-2329 Cell: (787) 399-7635 * [[alternative HTML version deleted]]
______________________________________________ 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.