情节分裂 date/time 过夜(而不是 0 - 24 小时,12 - 24 和 0 - 12)

Plot split date/time over night (instead 0 - 24 hours, 12 - 24 and 0 - 12)

我需要知道如何将一个从 0 到 24 小时的情节拆分为 12 到 24 和 0 到 12。因此我想在情节中间有半夜。

# sample data
date <- strptime(paste0("2014-",c(rep(sample(90:300, 100),4))), "%Y-%j")
h <- c(rep(paste(sprintf("%02d",as.numeric(sample(c(0:7,22:23))), 10),
             sample(10:59, 50),sep=":"),8))
# plot data
hour <- strptime(paste(date, h), "%Y-%m-%d %H:%M")
time <- difftime(hour, date , units="hours")
startMonth <- as.POSIXct(as.Date("2014-01-01", format="%Y-%m-%d"))
endMonth <- as.POSIXct(as.Date("2014-12-31", format="%Y-%m-%d"))
plot(x=date, y=time, xlim=c(startMonth, endMonth), ylim=c(24, 0) )

目前结果如下所示: http://i.stack.imgur.com/5rqu1.png

我的目标是午夜线在情节的中间。有什么线索吗?

plot(x=date, y=time - 24 * (time > 12), 
     xlim=c(startMonth, endMonth), ylim=c(12,-12), 
     yaxt = "none",
     ylab = "time")

breaks <- pretty(range(12, -12))
axis(2, at = breaks,
     label = breaks + 24 * (breaks < 0 ))