Two things I see. First is that par needs to be called _before_ the
plot (although its effects will persist if you need to keep hacking
away) and the second is that yaxp is expecting numeric arguments
(which you are offering) but in your case these will need to be the
numeric values in a Date-aligned version of those DateTimes used in
your mydat arguments. POSIXct is the number of seconds since the origin.
--
David.
On Oct 11, 2010, at 6:56 PM, Tim Clark 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@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.
David Winsemius, MD
West Hartford, CT
______________________________________________
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.