[R] Plotting times at night and getting plot limits correct
Richard M. Heiberger
rmh at temple.edu
Tue May 12 17:20:29 CEST 2015
>From the full data-time value subtract 18:00:00.
This places the times you are interested in into the range 00:00:00 - 12:00:00
Remove the date from these adjusted date-time values and plot y
against the new times.
Take control of the tick-labels and display 18:00 - 0600 instead of
the default 00:00 - 12:00
On Tue, May 12, 2015 at 10:34 AM, Bob O'Hara <rni.boh at gmail.com> wrote:
> I'm helping colleagues with analysis of frog calls at night, and they
> want to plot call statistics against time. This means we hit a
> problem: we want the x-axis to start at (say) 18:00 and end at (say)
> 06:00. I'm reluctant to use the date as well, because we have data
> from several dates, but only want to plot against time of day.
> Here's some code to illustrate the problem (don't worry about the data
> being outside the range of the plot: this is only for illustration).
> Times <- chron(times.=paste(c(18:23,0:9),":30:00", sep=""))
> Thing <- rnorm(length(Times)) # just something for the y-axis
> plot(Times,Thing) # x-axis wrong
> plot(Times,Thing, xlim=chron(times.=c("05:00:00", "18:00:00"))) # x-axis right
> plot(Times,Thing, xlim=chron(times.=c("18:00:00", "05:00:00"))) #
> would like this to work...
> Can anyone suggest a solution?
> Bob O'Hara
> Biodiversity and Climate Research Centre
> Senckenberganlage 25
> D-60325 Frankfurt am Main,
> Tel: +49 69 798 40226
> Mobile: +49 1515 888 5440
> WWW: http://www.bik-f.de/root/index.php?page_id=219
> Blog: http://occamstypewriter.org/boboh/
> Journal of Negative Results - EEB: www.jnr-eeb.org
> R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help