[R] (no subject)
jim holtman
jholtman at gmail.com
Tue Oct 12 02:09:50 CEST 2010
use 'axis' with 'at=' and 'labels=' to put your own labels on the axis.
Have to guess at your data since you did not provide a reproducible example:
x <- seq(as.POSIXct('2010-10-11 00:00'), as.POSIXct('2010-10-12
00:00'), length = 20)
plot(x, x, type = 'o', yaxt = 'n')
axis.POSIXct(2, at = seq(as.POSIXct('2010-10-11 02:00'),
as.POSIXct('2010-10-12 00:00'),
by = '6 hours'))
On Mon, Oct 11, 2010 at 6:56 PM, Tim Clark <mudiver1200 at yahoo.com> wrote:
> Dear List,
>
> I am trying to plot date vs. time, but am having problems getting my y-axis
> labels how I want them. When left on its own R plots time at 6 hour intervals
> from 03:00 to 23:00. I am wanting 6 hour intervals from 2:00 to 22:00. I
> realize yaxp doesn't work in plot(), so I am trying to get it to work in par().
> However, now I get the ticks where I want them but the time is output as a very
> big number (serial time?). I have also tried axis() using at= and also get
> seriel time numbers. Any suggestions on how to format time on an axis?
>
> mydat$Date<-as.POSIXct(as.character(mydat$Date), format=c("%m/%d/%Y"))
> mydat$Time<-as.POSIXct(as.character(mydat$Time), format=c("%H:%M:%S"))
>
> plot(mydat$DateTime,mydat$Time, xlab=c("Date"), ylab=c("Time"),
> xlim=c(min(mydat$DateTime),max(mydat$DateTime)),
> ylim=c(min(mydat$Time),max(mydat$Time)),
> yaxt="n",
> yaxs="i",
> pch=19, cex=.4,
> type="n")
>
> par(yaxp=c(as.POSIXct(as.character("02:00"),
> format=c("%H:%M")),as.POSIXct(as.character("22:00"), format=c("%H:%M")),5))
> axis(2)
>
>
> Thanks,
>
> Tim
> Tim Clark
>
> Marine Ecologist
> National Park of American Samoa
>
>
>
>
> ______________________________________________
> R-help at 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.
>
--
Jim Holtman
Cincinnati, OH
+1 513 646 9390
What is the problem that you are trying to solve?
More information about the R-help
mailing list