[R] Tick mark alignment for POSIXct data

Gabor Grothendieck ggrothendieck at gmail.com
Tue Apr 18 01:00:02 CEST 2006


Read the R News 4/1 help desk article which specifically discusses this.

On 4/17/06, jim holtman <jholtman at gmail.com> wrote:
> I am using POSIXct objects to store my date/time information.  If I am
> plotting less that 2 days worth of data, I get the correct tick marks on the
> x-axis which is showing the 'day HH:MM' and these line up with the data
> points.
>
> If the data spans more than 2 days, the tick marks are now off.  In the data
> below, I am creating some sample data and plotting the points.  I am in the
> Eastern Timezone.  When the second plot is generated, the tick marks are 4
> hours behind the actual time; it appears that the data is being plotted in
> GMT, but the tick marks are EDT.  I as looking in axis.POSIXct and it
> appears that the rounding that is done for 'pretty printing' the x-axis is
> normalized to GMT, so that the tick marks are plotted 4 hours before the
> data points.
>
> Is there a way of carrying the time zone into axis.POSIXct so that the ticks
> marks are generated in the correct locations?
>
> ###=========test script   ---   Eastern Time Zone===========
> # generate less than 2 days of data points
> x.1 <- seq(as.POSIXct('2006-6-1 00:00:00'), as.POSIXct('2006-6-2 12:00:00'),
> by='2 hours')
> plot(x.1, seq(length(x.1)), main='tick marks aligned') # default
>
> # now setup 4 days worth of data; tick marks don't line up as expected
> x.1 <- seq(as.POSIXct('2006-6-1 00:00:00'), as.POSIXct('2006-6-5 00:00:00'),
> by='day')
> plot(x.1, seq(length(x.1)), main='tick marks not aligned') # default
>
>
>
>
> --
> Jim Holtman
> Cincinnati, OH
> +1 513 646 9390 (Cell)
> +1 513 247 0281 (Home)
>
> What the problem you are trying to solve?
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>




More information about the R-help mailing list