[R] Changing Tick Marks for Date Plots

Heywood, Giles Giles.Heywood at CommerzbankIB.com
Tue Sep 9 17:06:52 CEST 2003


The way to control number of tickmarks in plot is via par(lab)

par(lab=c(5,5,7)) #the default
plot(rnorm(20),rnorm(20))
par(lab=3*c(5,5,7))
plot(rnorm(20),rnorm(20))

However this does not work for axis.POSIXct, which the function
called by the plot method for 'its'.  I am not sure why this is.

The parameter that controls the location of tickmarks and labels
in axis.POSIXct is 'at'.  You could use this, thus:

plot(x$dates,x$values,type="l",xaxt = "n")
axis.POSIXct(x = x$dates, side = 1,
at=x$dates[seq(1,500,100)],format="%b-%Y")

At present, the plot method for 'its' class does not pass the 'at'
parameter through to axis.POSIXct.  It could, and probably will, 
in the next version.  You could easily do the fix.

Giles

> -----Original Message-----
> From: Sean Carmody [mailto:seancarmody at yahoo.com]
> Sent: 09 September 2003 14:26
> To: r-help at stat.math.ethz.ch
> Subject: [R] Changing Tick Marks for Date Plots
> 
> 
> I have been experimenting with various approaches to
> plotting (irregular) time-series with reasonable
> success. One thing I have been able to do is change
> the number of tick marks on the axis. Consider the
> following simple example:
> 
> > x <- as.data.frame(matrix(ncol=2,nrow=500))
> > names(x) <- c("dates","values")
> > x$dates <- as.POSIXct(Sys.time()+1:500*86400)
> > x$values <- cumsum(rnorm(500))))
> > plot(x$dates,x$values,type="l")
> 
> The resulting plot only has two tick-marks: 2004 and
> 2005 (depending on today's date!). I have the same
> problem when I use the "its" library:
> 
> > library(its)
> > plot(as.its(x),format="%b-%Y")
> 
> Any suggestions would be greatly appreciated.
> 
> Regards,
> Sean.
> 
> 
> 
> http://search.yahoo.com.au - Yahoo! Search
> - Looking for more? Try the new Yahoo! Search
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 


********************************************************************** 
This is a commercial communication from Commerzbank AG.\ \ T...{{dropped}}




More information about the R-help mailing list