y 轴为 "times" 的时间序列图

Time Series plot with "times" in y-axis

假设我有一些事件的完成时间。

completion_data <- data.frame(
    date=c("2009-05-04", "2010-04-07", "2011-04-02", "2011-05-06",
           "2012-06-03", "2012-07-09", "2013-09-03", "2014-02-01"),
    time_taken=c("1:53:01", "1:50:01", "1:30:01", "1:29:01", 
                 "1:28:03", "1:20:01", "1:15:11", "1:12:24"))

library(zoo)
library(chron)
completion_data$date <- as.Date(completion_data$date)
completion_data$time_taken <- chron(times.=completion_data$time_taken)

我想创建一个时间序列图,其中 x 轴为日期,y 轴为所用时间。

completion_ts <- zoo(completion_data$time_taken, completion_data$date)
plot(completion_ts, ylab="Time (H:M:S)", xlab="Date", type='o')

但是,y 轴没有我想要的 H:M:S 格式。例如,第一个点对应于 1:53:01 的时间(即 1 小时 53 分 1 秒),我希望 y 轴使用这种格式。

自己在Y轴上贴标签:

plot(completion_ts, ylab = "Time (H:M:S)", xlab = "Date", type = 'o', yaxt = "n")
tt <- seq(times("00:00:00"), times("23:59:59"), times("00:10:00"))
axis(2, tt, sub(":00$", "", times(tt)))