我已經閱讀了一系列發生事件的37個日期和時間。它現在坐在一個POSIXlt對象上。我想要一個關於每天事件發生的時間的圖形表示。所以x軸應該是日期,y軸應該是一天的時間。使用ggplot2在x軸上繪製日期和在y軸上繪製時間
然後我試着用GGPLOT2
qplot(day(dttm), hour(dttm))
這就是那種我想要的陰謀,但它不具備分鐘的分辨率。我如何在y軸中包含小時和分鐘?
下面是一些樣本數據
dttm
[1] "2011-11-16 10:39:20" "2011-11-16 10:56:32" "2011-11-16 11:52:43" "2011-11-16 12:10:42"
[5] "2011-11-16 13:10:13" "2011-11-16 13:41:10" "2011-11-16 13:48:07" "2011-11-16 14:54:04"
[9] "2011-11-17 07:05:23" "2011-11-17 07:34:24" "2011-11-17 07:53:01" "2011-11-17 07:57:04"
[13] "2011-11-17 08:09:16" "2011-11-17 08:23:43" "2011-11-17 10:20:54" "2011-11-17 10:45:13"
[17] "2011-11-17 10:49:32" "2011-11-17 11:16:08" "2011-11-17 11:24:05" "2011-11-17 11:50:11"
[21] "2011-11-17 11:52:47" "2011-11-17 11:54:42" "2011-11-17 11:55:25" "2011-11-17 11:57:34"
[25] "2011-11-17 12:06:15" "2011-11-17 12:08:05" "2011-11-17 12:08:33" "2011-11-17 12:30:13"
[29] "2011-11-17 13:24:41" "2011-11-17 13:44:41" "2011-11-17 13:48:55" "2011-11-17 14:59:08"
[33] "2011-11-18 06:46:17" "2011-11-18 07:52:50" "2011-11-18 08:31:22" "2011-11-18 08:33:43"
[37] "2011-11-18 08:50:08"
這裏是dput文件
structure(list(sec = c(20, 32, 43, 42, 13, 10, 7, 4, 23, 24,
1, 4, 16, 43, 54, 13, 32, 8, 5, 11, 47, 42, 25, 34, 15, 5, 33,
13, 41, 41, 55, 8, 17, 50, 22, 43, 8), min = c(39L, 56L, 52L,
10L, 10L, 41L, 48L, 54L, 5L, 34L, 53L, 57L, 9L, 23L, 20L, 45L,
49L, 16L, 24L, 50L, 52L, 54L, 55L, 57L, 6L, 8L, 8L, 30L, 24L,
44L, 48L, 59L, 46L, 52L, 31L, 33L, 50L), hour = c(10L, 10L, 11L,
12L, 13L, 13L, 13L, 14L, 7L, 7L, 7L, 7L, 8L, 8L, 10L, 10L, 10L,
11L, 11L, 11L, 11L, 11L, 11L, 11L, 12L, 12L, 12L, 12L, 13L, 13L,
13L, 14L, 6L, 7L, 8L, 8L, 8L), mday = c(16L, 16L, 16L, 16L, 16L,
16L, 16L, 16L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L, 17L,
17L, 18L, 18L, 18L, 18L, 18L), mon = c(10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L, 10L,
10L, 10L, 10L, 10L, 10L, 10L), year = c(111L, 111L, 111L, 111L,
111L, 111L, 111L, 111L, 111L, 111L, 111L, 111L, 111L, 111L, 111L,
111L, 111L, 111L, 111L, 111L, 111L, 111L, 111L, 111L, 111L, 111L,
111L, 111L, 111L, 111L, 111L, 111L, 111L, 111L, 111L, 111L, 111L
), wday = c(3L, 3L, 3L, 3L, 3L, 3L, 3L, 3L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L, 4L,
4L, 4L, 4L, 5L, 5L, 5L, 5L, 5L), yday = c(319L, 319L, 319L, 319L,
319L, 319L, 319L, 319L, 320L, 320L, 320L, 320L, 320L, 320L, 320L,
320L, 320L, 320L, 320L, 320L, 320L, 320L, 320L, 320L, 320L, 320L,
320L, 320L, 320L, 320L, 320L, 320L, 321L, 321L, 321L, 321L, 321L
), isdst = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L,
0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L)), .Names = c("sec", "min",
"hour", "mday", "mon", "year", "wday", "yday", "isdst"), class = c("POSIXlt",
"POSIXt"))
唉,小時(dttm)* 3600不提供分和秒的分辨率。它一直重複繪製所有時間,四捨五入到最近的整個小時。 – Farrel
@Farrel好吧,我以爲你只是想修改規模。回答編輯。 – Andrie