1

这似乎相对简单,并且可能使用 scale_x_datetime 或 scale_x_discrete 是可行的。

我有一个时间增量列,例如秒表:

[1] 0:00:01 0:00:02 0:00:03 0:00:04 0:00:05 0:00:06
1800 Levels: 0:00:01 0:00:02 0:00:03 0:00:04 0:00:05 0:00:06 0:00:07 ... 0:30:00

使用 ggplot 如何将 x 轴标签设置为 30 秒间隔?

可重现的数据:

structure(list(`somedata$Time` = structure(1:4, .Label = c("0:00:01", 
"0:00:02", "0:00:03", "0:00:04", "0:00:05", "0:00:06", "0:00:07", 
"0:00:08", "0:00:09", "0:00:10", "0:00:11", "0:00:12", "0:00:13", 
"0:00:14", "0:00:15", "0:00:16", "0:00:17", "0:00:18", "0:00:19", 
"0:00:20", "0:00:21", "0:00:22", "0:00:23", "0:00:24", "0:00:25", 
"0:00:26", "0:00:27", "0:00:28", "0:00:29", "0:00:30", "0:00:31", 
"0:00:32", "0:00:33", "0:00:34", "0:00:35", "0:00:36", "0:00:37", 
"0:00:38", "0:00:39", "0:00:40", "0:00:41", "0:00:42", "0:00:43", 
"0:00:44", "0:00:45", "0:00:46", "0:00:47", "0:00:48", "0:00:49", 
"0:00:50", "0:00:51", "0:00:52", "0:00:53", "0:00:54", "0:00:55", 
"0:00:56", "0:00:57", "0:00:58", "0:00:59", "0:01:00", "0:01:01", 
"0:01:02", "0:01:03", "0:01:04", "0:01:05", "0:01:06", "0:01:07", 
"0:01:08", "0:01:09", "0:01:10", "0:01:11", "0:01:12", "0:01:13", 
"0:01:14", "0:01:15", "0:01:16", "0:01:17", "0:01:18", "0:01:19", 
"0:01:20", "0:01:21", "0:01:22", "0:01:23", "0:01:24", "0:01:25", 
"0:01:26", "0:01:27", "0:01:28", "0:01:29", "0:01:30", "0:01:31", 
"0:01:32", "0:01:33", "0:01:34", "0:01:35", "0:01:36", "0:01:37", 
"0:01:38", "0:01:39", "0:01:40", "0:01:41", "0:01:42", "0:01:43", 
"0:01:44", "0:01:45", "0:01:46", "0:01:47", "0:01:48", "0:01:49", 
"0:01:50", "0:01:51", "0:01:52", "0:01:53", "0:01:54", "0:01:55", 
"0:01:56", "0:01:57", "0:01:58", "0:01:59", "0:02:00", "0:02:01", 
"0:02:02", "0:02:03", "0:02:04", "0:02:05", "0:02:06", "0:02:07", 
"0:02:08", "0:02:09", "0:02:10", "0:02:11", "0:02:12", "0:02:13", 
"0:02:14", "0:02:15", "0:02:16", "0:02:17", "0:02:18", "0:02:19", 
"0:02:20", "0:02:21", "0:02:22", "0:02:23", "0:02:24", "0:02:25", 
"0:02:26", "0:02:27", "0:02:28", "0:02:29", "0:02:30", "0:02:31", 
"0:02:32", "0:02:33", "0:02:34", "0:02:35", "0:02:36", "0:02:37", 
"0:02:38", "0:02:39", "0:02:40", "0:02:41", "0:02:42", "0:02:43", 
"0:02:44", "0:02:45", "0:02:46", "0:02:47", "0:02:48", "0:02:49", 
"0:02:50", "0:02:51", "0:02:52", "0:02:53", "0:02:54", "0:02:55", 
"0:02:56", "0:02:57", "0:02:58", "0:02:59", "0:03:00", "0:03:01", 
"0:03:02", "0:03:03", "0:03:04", "0:03:05", "0:03:06", "0:03:07", 
"0:03:08", "0:03:09", "0:03:10", "0:03:11", "0:03:12", "0:03:13", 
"0:03:14", "0:03:15", "0:03:16", "0:03:17", "0:03:18", "0:03:19", 
"0:03:20", "0:03:21", "0:03:22", "0:03:23", "0:03:24", "0:03:25", 
"0:03:26", "0:03:27", "0:03:28", "0:03:29", "0:03:30", "0:03:31", 
"0:03:32", "0:03:33", "0:03:34", "0:03:35", "0:03:36", "0:03:37", 
"0:03:38", "0:03:39", "0:03:40", "0:03:41", "0:03:42", "0:03:43", 
"0:03:44", "0:03:45", "0:03:46", "0:03:47", "0:03:48", "0:03:49", 
"0:03:50", "0:03:51", "0:03:52", "0:03:53", "0:03:54", "0:03:55", 
"0:03:56", "0:03:57", "0:03:58", "0:03:59", "0:04:00", "0:04:01", 
"0:04:02", "0:04:03", "0:04:04", "0:04:05", "0:04:06", "0:04:07", 
"0:04:08", "0:04:09", "0:04:10", "0:04:11", "0:04:12", "0:04:13", 
"0:04:14", "0:04:15", "0:04:16", "0:04:17", "0:04:18", "0:04:19", 
"0:04:20", "0:04:21", "0:04:22", "0:04:23", "0:04:24", "0:04:25", 
"0:04:26", "0:04:27", "0:04:28", "0:04:29", "0:04:30", "0:04:31", 
"0:04:32", "0:04:33", "0:04:34", "0:04:35", "0:04:36", "0:04:37", 
"0:04:38", "0:04:39", "0:04:40", "0:04:41", "0:04:42", "0:04:43", 
"0:04:44", "0:04:45", "0:04:46", "0:04:47", "0:04:48", "0:04:49", 
"0:04:50", "0:04:51", "0:04:52", "0:04:53", "0:04:54", "0:04:55", 
"0:04:56", "0:04:57", "0:04:58", "0:04:59", "0:05:00", "0:05:01", 
"0:05:02", "0:05:03", "0:05:04", "0:05:05", "0:05:06", "0:05:07", 
"0:05:08", "0:05:09", "0:05:10", "0:05:11", "0:05:12", "0:05:13", 
"0:05:14", "0:05:15", "0:05:16", "0:05:17", "0:05:18", "0:05:19", 
"0:05:20", "0:05:21", "0:05:22", "0:05:23", "0:05:24", "0:05:25", 
"0:05:26", "0:05:27", "0:05:28", "0:05:29", "0:05:30", "0:05:31", 
"0:05:32", "0:05:33", "0:05:34", "0:05:35", "0:05:36", "0:05:37", 
"0:05:38", "0:05:39", "0:05:40", "0:05:41", "0:05:42", "0:05:43", 
"0:05:44", "0:05:45", "0:05:46", "0:05:47", "0:05:48", "0:05:49", 
"0:05:50", "0:05:51", "0:05:52", "0:05:53", "0:05:54", "0:05:55", 
"0:05:56", "0:05:57", "0:05:58", "0:05:59", "0:06:00", "0:06:01", 
"0:06:02", "0:06:03", "0:06:04", "0:06:05", "0:06:06", "0:06:07", 
"0:06:08", "0:06:09", "0:06:10", "0:06:11", "0:06:12", "0:06:13", 
"0:06:14", "0:06:15", "0:06:16", "0:06:17", "0:06:18", "0:06:19", 
"0:06:20", "0:06:21", "0:06:22", "0:06:23", "0:06:24", "0:06:25", 
"0:06:26", "0:06:27", "0:06:28", "0:06:29", "0:06:30", "0:06:31", 
"0:06:32", "0:06:33", "0:06:34", "0:06:35", "0:06:36", "0:06:37", 
"0:06:38", "0:06:39", "0:06:40", "0:06:41", "0:06:42", "0:06:43", 
"0:06:44", "0:06:45", "0:06:46", "0:06:47", "0:06:48", "0:06:49", 
"0:06:50", "0:06:51", "0:06:52", "0:06:53", "0:06:54", "0:06:55", 
"0:06:56", "0:06:57", "0:06:58", "0:06:59", "0:07:00", "0:07:01", 
"0:07:02", "0:07:03", "0:07:04", "0:07:05", "0:07:06", "0:07:07", 
"0:07:08", "0:07:09", "0:07:10", "0:07:11", "0:07:12", "0:07:13", 
"0:07:14", "0:07:15", "0:07:16", "0:07:17", "0:07:18", "0:07:19", 
"0:07:20", "0:07:21", "0:07:22", "0:07:23", "0:07:24", "0:07:25", 
"0:07:26", "0:07:27", "0:07:28", "0:07:29", "0:07:30", "0:07:31", 
"0:07:32", "0:07:33", "0:07:34", "0:07:35", "0:07:36", "0:07:37", 
"0:07:38", "0:07:39", "0:07:40", "0:07:41", "0:07:42", "0:07:43", 
"0:07:44", "0:07:45", "0:07:46", "0:07:47", "0:07:48", "0:07:49", 
"0:07:50", "0:07:51", "0:07:52", "0:07:53", "0:07:54", "0:07:55", 
"0:07:56", "0:07:57", "0:07:58", "0:07:59", "0:08:00", "0:08:01", 
"0:08:02", "0:08:03", "0:08:04", "0:08:05", "0:08:06", "0:08:07", 
"0:08:08", "0:08:09", "0:08:10", "0:08:11", "0:08:12", "0:08:13", 
"0:08:14", "0:08:15", "0:08:16", "0:08:17", "0:08:18", "0:08:19", 
"0:08:20", "0:08:21", "0:08:22", "0:08:23", "0:08:24", "0:08:25", 
"0:08:26", "0:08:27", "0:08:28", "0:08:29", "0:08:30", "0:08:31", 
"0:08:32", "0:08:33", "0:08:34", "0:08:35", "0:08:36", "0:08:37", 
"0:08:38", "0:08:39", "0:08:40", "0:08:41", "0:08:42", "0:08:43", 
"0:08:44", "0:08:45", "0:08:46", "0:08:47", "0:08:48", "0:08:49", 
"0:08:50", "0:08:51", "0:08:52", "0:08:53", "0:08:54", "0:08:55", 
"0:08:56", "0:08:57", "0:08:58", "0:08:59", "0:09:00", "0:09:01", 
"0:09:02", "0:09:03", "0:09:04", "0:09:05", "0:09:06", "0:09:07", 
"0:09:08", "0:09:09", "0:09:10", "0:09:11", "0:09:12", "0:09:13", 
"0:09:14", "0:09:15", "0:09:16", "0:09:17", "0:09:18", "0:09:19", 
"0:09:20", "0:09:21", "0:09:22", "0:09:23", "0:09:24", "0:09:25", 
"0:09:26", "0:09:27", "0:09:28", "0:09:29", "0:09:30", "0:09:31", 
"0:09:32", "0:09:33", "0:09:34", "0:09:35", "0:09:36", "0:09:37", 
"0:09:38", "0:09:39", "0:09:40", "0:09:41", "0:09:42", "0:09:43", 
"0:09:44", "0:09:45", "0:09:46", "0:09:47", "0:09:48", "0:09:49", 
"0:09:50", "0:09:51", "0:09:52", "0:09:53", "0:09:54", "0:09:55", 
"0:09:56", "0:09:57", "0:09:58", "0:09:59", "0:10:00", "0:10:01", 
"0:10:02", "0:10:03", "0:10:04", "0:10:05", "0:10:06", "0:10:07", 
"0:10:08", "0:10:09", "0:10:10", "0:10:11", "0:10:12", "0:10:13", 
"0:10:14", "0:10:15", "0:10:16", "0:10:17", "0:10:18", "0:10:19", 
"0:10:20", "0:10:21", "0:10:22", "0:10:23", "0:10:24", "0:10:25", 
"0:10:26", "0:10:27", "0:10:28", "0:10:29", "0:10:30", "0:10:31", 
"0:10:32", "0:10:33", "0:10:34", "0:10:35", "0:10:36", "0:10:37", 
"0:10:38", "0:10:39", "0:10:40", "0:10:41", "0:10:42", "0:10:43", 
"0:10:44", "0:10:45", "0:10:46", "0:10:47", "0:10:48", "0:10:49", 
"0:10:50", "0:10:51", "0:10:52", "0:10:53", "0:10:54", "0:10:55", 
"0:10:56", "0:10:57", "0:10:58", "0:10:59", "0:11:00", "0:11:01", 
"0:11:02", "0:11:03", "0:11:04", "0:11:05", "0:11:06", "0:11:07", 
"0:11:08", "0:11:09", "0:11:10", "0:11:11", "0:11:12", "0:11:13", 
"0:11:14", "0:11:15", "0:11:16", "0:11:17", "0:11:18", "0:11:19", 
"0:11:20", "0:11:21", "0:11:22", "0:11:23", "0:11:24", "0:11:25", 
"0:11:26", "0:11:27", "0:11:28", "0:11:29", "0:11:30", "0:11:31", 
"0:11:32", "0:11:33", "0:11:34", "0:11:35", "0:11:36", "0:11:37", 
"0:11:38", "0:11:39", "0:11:40", "0:11:41", "0:11:42", "0:11:43", 
"0:11:44", "0:11:45", "0:11:46", "0:11:47", "0:11:48", "0:11:49", 
"0:11:50", "0:11:51", "0:11:52", "0:11:53", "0:11:54", "0:11:55", 
"0:11:56", "0:11:57", "0:11:58", "0:11:59", "0:12:00", "0:12:01", 
"0:12:02", "0:12:03", "0:12:04", "0:12:05", "0:12:06", "0:12:07", 
"0:12:08", "0:12:09", "0:12:10", "0:12:11", "0:12:12", "0:12:13", 
"0:12:14", "0:12:15", "0:12:16", "0:12:17", "0:12:18", "0:12:19", 
"0:12:20", "0:12:21", "0:12:22", "0:12:23", "0:12:24", "0:12:25", 
"0:12:26", "0:12:27", "0:12:28", "0:12:29", "0:12:30", "0:12:31", 
"0:12:32", "0:12:33", "0:12:34", "0:12:35", "0:12:36", "0:12:37", 
"0:12:38", "0:12:39", "0:12:40", "0:12:41", "0:12:42", "0:12:43", 
"0:12:44", "0:12:45", "0:12:46", "0:12:47", "0:12:48", "0:12:49", 
"0:12:50", "0:12:51", "0:12:52", "0:12:53", "0:12:54", "0:12:55", 
"0:12:56", "0:12:57", "0:12:58", "0:12:59", "0:13:00", "0:13:01", 
"0:13:02", "0:13:03", "0:13:04", "0:13:05", "0:13:06", "0:13:07", 
"0:13:08", "0:13:09", "0:13:10", "0:13:11", "0:13:12", "0:13:13", 
"0:13:14", "0:13:15", "0:13:16", "0:13:17", "0:13:18", "0:13:19", 
"0:13:20", "0:13:21", "0:13:22", "0:13:23", "0:13:24", "0:13:25", 
"0:13:26", "0:13:27", "0:13:28", "0:13:29", "0:13:30", "0:13:31", 
"0:13:32", "0:13:33", "0:13:34", "0:13:35", "0:13:36", "0:13:37", 
"0:13:38", "0:13:39", "0:13:40", "0:13:41", "0:13:42", "0:13:43", 
"0:13:44", "0:13:45", "0:13:46", "0:13:47", "0:13:48", "0:13:49", 
"0:13:50", "0:13:51", "0:13:52", "0:13:53", "0:13:54", "0:13:55", 
"0:13:56", "0:13:57", "0:13:58", "0:13:59", "0:14:00", "0:14:01", 
"0:14:02", "0:14:03", "0:14:04", "0:14:05", "0:14:06", "0:14:07", 
"0:14:08", "0:14:09", "0:14:10", "0:14:11", "0:14:12", "0:14:13", 
"0:14:14", "0:14:15", "0:14:16", "0:14:17", "0:14:18", "0:14:19", 
"0:14:20", "0:14:21", "0:14:22", "0:14:23", "0:14:24", "0:14:25", 
"0:14:26", "0:14:27", "0:14:28", "0:14:29", "0:14:30", "0:14:31", 
"0:14:32", "0:14:33", "0:14:34", "0:14:35", "0:14:36", "0:14:37", 
"0:14:38", "0:14:39", "0:14:40", "0:14:41", "0:14:42", "0:14:43", 
"0:14:44", "0:14:45", "0:14:46", "0:14:47", "0:14:48", "0:14:49", 
"0:14:50", "0:14:51", "0:14:52", "0:14:53", "0:14:54", "0:14:55", 
"0:14:56", "0:14:57", "0:14:58", "0:14:59", "0:15:00", "0:15:01", 
"0:15:02", "0:15:03", "0:15:04", "0:15:05", "0:15:06", "0:15:07", 
"0:15:08", "0:15:09", "0:15:10", "0:15:11", "0:15:12", "0:15:13", 
"0:15:14", "0:15:15", "0:15:16", "0:15:17", "0:15:18", "0:15:19", 
"0:15:20", "0:15:21", "0:15:22", "0:15:23", "0:15:24", "0:15:25", 
"0:15:26", "0:15:27", "0:15:28", "0:15:29", "0:15:30", "0:15:31", 
"0:15:32", "0:15:33", "0:15:34", "0:15:35", "0:15:36", "0:15:37", 
"0:15:38", "0:15:39", "0:15:40", "0:15:41", "0:15:42", "0:15:43", 
"0:15:44", "0:15:45", "0:15:46", "0:15:47", "0:15:48", "0:15:49", 
"0:15:50", "0:15:51", "0:15:52", "0:15:53", "0:15:54", "0:15:55", 
"0:15:56", "0:15:57", "0:15:58", "0:15:59", "0:16:00", "0:16:01", 
"0:16:02", "0:16:03", "0:16:04", "0:16:05", "0:16:06", "0:16:07", 
"0:16:08", "0:16:09", "0:16:10", "0:16:11", "0:16:12", "0:16:13", 
"0:16:14", "0:16:15", "0:16:16", "0:16:17", "0:16:18", "0:16:19", 
"0:16:20", "0:16:21", "0:16:22", "0:16:23", "0:16:24", "0:16:25", 
"0:16:26", "0:16:27", "0:16:28", "0:16:29", "0:16:30", "0:16:31", 
"0:16:32", "0:16:33", "0:16:34", "0:16:35", "0:16:36", "0:16:37", 
"0:16:38", "0:16:39", "0:16:40", "0:16:41", "0:16:42", "0:16:43", 
"0:16:44", "0:16:45", "0:16:46", "0:16:47", "0:16:48", "0:16:49", 
"0:16:50", "0:16:51", "0:16:52", "0:16:53", "0:16:54", "0:16:55", 
"0:16:56", "0:16:57", "0:16:58", "0:16:59", "0:17:00", "0:17:01", 
"0:17:02", "0:17:03", "0:17:04", "0:17:05", "0:17:06", "0:17:07", 
"0:17:08", "0:17:09", "0:17:10", "0:17:11", "0:17:12", "0:17:13", 
"0:17:14", "0:17:15", "0:17:16", "0:17:17", "0:17:18", "0:17:19", 
"0:17:20", "0:17:21", "0:17:22", "0:17:23", "0:17:24", "0:17:25", 
"0:17:26", "0:17:27", "0:17:28", "0:17:29", "0:17:30", "0:17:31", 
"0:17:32", "0:17:33", "0:17:34", "0:17:35", "0:17:36", "0:17:37", 
"0:17:38", "0:17:39", "0:17:40", "0:17:41", "0:17:42", "0:17:43", 
"0:17:44", "0:17:45", "0:17:46", "0:17:47", "0:17:48", "0:17:49", 
"0:17:50", "0:17:51", "0:17:52", "0:17:53", "0:17:54", "0:17:55", 
"0:17:56", "0:17:57", "0:17:58", "0:17:59", "0:18:00", "0:18:01", 
"0:18:02", "0:18:03", "0:18:04", "0:18:05", "0:18:06", "0:18:07", 
"0:18:08", "0:18:09", "0:18:10", "0:18:11", "0:18:12", "0:18:13", 
"0:18:14", "0:18:15", "0:18:16", "0:18:17", "0:18:18", "0:18:19", 
"0:18:20", "0:18:21", "0:18:22", "0:18:23", "0:18:24", "0:18:25", 
"0:18:26", "0:18:27", "0:18:28", "0:18:29", "0:18:30", "0:18:31", 
"0:18:32", "0:18:33", "0:18:34", "0:18:35", "0:18:36", "0:18:37", 
"0:18:38", "0:18:39", "0:18:40", "0:18:41", "0:18:42", "0:18:43", 
"0:18:44", "0:18:45", "0:18:46", "0:18:47", "0:18:48", "0:18:49", 
"0:18:50", "0:18:51", "0:18:52", "0:18:53", "0:18:54", "0:18:55", 
"0:18:56", "0:18:57", "0:18:58", "0:18:59", "0:19:00", "0:19:01", 
"0:19:02", "0:19:03", "0:19:04", "0:19:05", "0:19:06", "0:19:07", 
"0:19:08", "0:19:09", "0:19:10", "0:19:11", "0:19:12", "0:19:13", 
"0:19:14", "0:19:15", "0:19:16", "0:19:17", "0:19:18", "0:19:19", 
"0:19:20", "0:19:21", "0:19:22", "0:19:23", "0:19:24", "0:19:25", 
"0:19:26", "0:19:27", "0:19:28", "0:19:29", "0:19:30", "0:19:31", 
"0:19:32", "0:19:33", "0:19:34", "0:19:35", "0:19:36", "0:19:37", 
"0:19:38", "0:19:39", "0:19:40", "0:19:41", "0:19:42", "0:19:43", 
"0:19:44", "0:19:45", "0:19:46", "0:19:47", "0:19:48", "0:19:49", 
"0:19:50", "0:19:51", "0:19:52", "0:19:53", "0:19:54", "0:19:55", 
"0:19:56", "0:19:57", "0:19:58", "0:19:59", "0:20:00", "0:20:01", 
"0:20:02", "0:20:03", "0:20:04", "0:20:05", "0:20:06", "0:20:07", 
"0:20:08", "0:20:09", "0:20:10", "0:20:11", "0:20:12", "0:20:13", 
"0:20:14", "0:20:15", "0:20:16", "0:20:17", "0:20:18", "0:20:19", 
"0:20:20", "0:20:21", "0:20:22", "0:20:23", "0:20:24", "0:20:25", 
"0:20:26", "0:20:27", "0:20:28", "0:20:29", "0:20:30", "0:20:31", 
"0:20:32", "0:20:33", "0:20:34", "0:20:35", "0:20:36", "0:20:37", 
"0:20:38", "0:20:39", "0:20:40", "0:20:41", "0:20:42", "0:20:43", 
"0:20:44", "0:20:45", "0:20:46", "0:20:47", "0:20:48", "0:20:49", 
"0:20:50", "0:20:51", "0:20:52", "0:20:53", "0:20:54", "0:20:55", 
"0:20:56", "0:20:57", "0:20:58", "0:20:59", "0:21:00", "0:21:01", 
"0:21:02", "0:21:03", "0:21:04", "0:21:05", "0:21:06", "0:21:07", 
"0:21:08", "0:21:09", "0:21:10", "0:21:11", "0:21:12", "0:21:13", 
"0:21:14", "0:21:15", "0:21:16", "0:21:17", "0:21:18", "0:21:19", 
"0:21:20", "0:21:21", "0:21:22", "0:21:23", "0:21:24", "0:21:25", 
"0:21:26", "0:21:27", "0:21:28", "0:21:29", "0:21:30", "0:21:31", 
"0:21:32", "0:21:33", "0:21:34", "0:21:35", "0:21:36", "0:21:37", 
"0:21:38", "0:21:39", "0:21:40", "0:21:41", "0:21:42", "0:21:43", 
"0:21:44", "0:21:45", "0:21:46", "0:21:47", "0:21:48", "0:21:49", 
"0:21:50", "0:21:51", "0:21:52", "0:21:53", "0:21:54", "0:21:55", 
"0:21:56", "0:21:57", "0:21:58", "0:21:59", "0:22:00", "0:22:01", 
"0:22:02", "0:22:03", "0:22:04", "0:22:05", "0:22:06", "0:22:07", 
"0:22:08", "0:22:09", "0:22:10", "0:22:11", "0:22:12", "0:22:13", 
"0:22:14", "0:22:15", "0:22:16", "0:22:17", "0:22:18", "0:22:19", 
"0:22:20", "0:22:21", "0:22:22", "0:22:23", "0:22:24", "0:22:25", 
"0:22:26", "0:22:27", "0:22:28", "0:22:29", "0:22:30", "0:22:31", 
"0:22:32", "0:22:33", "0:22:34", "0:22:35", "0:22:36", "0:22:37", 
"0:22:38", "0:22:39", "0:22:40", "0:22:41", "0:22:42", "0:22:43", 
"0:22:44", "0:22:45", "0:22:46", "0:22:47", "0:22:48", "0:22:49", 
"0:22:50", "0:22:51", "0:22:52", "0:22:53", "0:22:54", "0:22:55", 
"0:22:56", "0:22:57", "0:22:58", "0:22:59", "0:23:00", "0:23:01", 
"0:23:02", "0:23:03", "0:23:04", "0:23:05", "0:23:06", "0:23:07", 
"0:23:08", "0:23:09", "0:23:10", "0:23:11", "0:23:12", "0:23:13", 
"0:23:14", "0:23:15", "0:23:16", "0:23:17", "0:23:18", "0:23:19", 
"0:23:20", "0:23:21", "0:23:22", "0:23:23", "0:23:24", "0:23:25", 
"0:23:26", "0:23:27", "0:23:28", "0:23:29", "0:23:30", "0:23:31", 
"0:23:32", "0:23:33", "0:23:34", "0:23:35", "0:23:36", "0:23:37", 
"0:23:38", "0:23:39", "0:23:40", "0:23:41", "0:23:42", "0:23:43", 
"0:23:44", "0:23:45", "0:23:46", "0:23:47", "0:23:48", "0:23:49", 
"0:23:50", "0:23:51", "0:23:52", "0:23:53", "0:23:54", "0:23:55", 
"0:23:56", "0:23:57", "0:23:58", "0:23:59", "0:24:00", "0:24:01", 
"0:24:02", "0:24:03", "0:24:04", "0:24:05", "0:24:06", "0:24:07", 
"0:24:08", "0:24:09", "0:24:10", "0:24:11", "0:24:12", "0:24:13", 
"0:24:14", "0:24:15", "0:24:16", "0:24:17", "0:24:18", "0:24:19", 
"0:24:20", "0:24:21", "0:24:22", "0:24:23", "0:24:24", "0:24:25", 
"0:24:26", "0:24:27", "0:24:28", "0:24:29", "0:24:30", "0:24:31", 
"0:24:32", "0:24:33", "0:24:34", "0:24:35", "0:24:36", "0:24:37", 
"0:24:38", "0:24:39", "0:24:40", "0:24:41", "0:24:42", "0:24:43", 
"0:24:44", "0:24:45", "0:24:46", "0:24:47", "0:24:48", "0:24:49", 
"0:24:50", "0:24:51", "0:24:52", "0:24:53", "0:24:54", "0:24:55", 
"0:24:56", "0:24:57", "0:24:58", "0:24:59", "0:25:00", "0:25:01", 
"0:25:02", "0:25:03", "0:25:04", "0:25:05", "0:25:06", "0:25:07", 
"0:25:08", "0:25:09", "0:25:10", "0:25:11", "0:25:12", "0:25:13", 
"0:25:14", "0:25:15", "0:25:16", "0:25:17", "0:25:18", "0:25:19", 
"0:25:20", "0:25:21", "0:25:22", "0:25:23", "0:25:24", "0:25:25", 
"0:25:26", "0:25:27", "0:25:28", "0:25:29", "0:25:30", "0:25:31", 
"0:25:32", "0:25:33", "0:25:34", "0:25:35", "0:25:36", "0:25:37", 
"0:25:38", "0:25:39", "0:25:40", "0:25:41", "0:25:42", "0:25:43", 
"0:25:44", "0:25:45", "0:25:46", "0:25:47", "0:25:48", "0:25:49", 
"0:25:50", "0:25:51", "0:25:52", "0:25:53", "0:25:54", "0:25:55", 
"0:25:56", "0:25:57", "0:25:58", "0:25:59", "0:26:00", "0:26:01", 
"0:26:02", "0:26:03", "0:26:04", "0:26:05", "0:26:06", "0:26:07", 
"0:26:08", "0:26:09", "0:26:10", "0:26:11", "0:26:12", "0:26:13", 
"0:26:14", "0:26:15", "0:26:16", "0:26:17", "0:26:18", "0:26:19", 
"0:26:20", "0:26:21", "0:26:22", "0:26:23", "0:26:24", "0:26:25", 
"0:26:26", "0:26:27", "0:26:28", "0:26:29", "0:26:30", "0:26:31", 
"0:26:32", "0:26:33", "0:26:34", "0:26:35", "0:26:36", "0:26:37", 
"0:26:38", "0:26:39", "0:26:40", "0:26:41", "0:26:42", "0:26:43", 
"0:26:44", "0:26:45", "0:26:46", "0:26:47", "0:26:48", "0:26:49", 
"0:26:50", "0:26:51", "0:26:52", "0:26:53", "0:26:54", "0:26:55", 
"0:26:56", "0:26:57", "0:26:58", "0:26:59", "0:27:00", "0:27:01", 
"0:27:02", "0:27:03", "0:27:04", "0:27:05", "0:27:06", "0:27:07", 
"0:27:08", "0:27:09", "0:27:10", "0:27:11", "0:27:12", "0:27:13", 
"0:27:14", "0:27:15", "0:27:16", "0:27:17", "0:27:18", "0:27:19", 
"0:27:20", "0:27:21", "0:27:22", "0:27:23", "0:27:24", "0:27:25", 
"0:27:26", "0:27:27", "0:27:28", "0:27:29", "0:27:30", "0:27:31", 
"0:27:32", "0:27:33", "0:27:34", "0:27:35", "0:27:36", "0:27:37", 
"0:27:38", "0:27:39", "0:27:40", "0:27:41", "0:27:42", "0:27:43", 
"0:27:44", "0:27:45", "0:27:46", "0:27:47", "0:27:48", "0:27:49", 
"0:27:50", "0:27:51", "0:27:52", "0:27:53", "0:27:54", "0:27:55", 
"0:27:56", "0:27:57", "0:27:58", "0:27:59", "0:28:00", "0:28:01", 
"0:28:02", "0:28:03", "0:28:04", "0:28:05", "0:28:06", "0:28:07", 
"0:28:08", "0:28:09", "0:28:10", "0:28:11", "0:28:12", "0:28:13", 
"0:28:14", "0:28:15", "0:28:16", "0:28:17", "0:28:18", "0:28:19", 
"0:28:20", "0:28:21", "0:28:22", "0:28:23", "0:28:24", "0:28:25", 
"0:28:26", "0:28:27", "0:28:28", "0:28:29", "0:28:30", "0:28:31", 
"0:28:32", "0:28:33", "0:28:34", "0:28:35", "0:28:36", "0:28:37", 
"0:28:38", "0:28:39", "0:28:40", "0:28:41", "0:28:42", "0:28:43", 
"0:28:44", "0:28:45", "0:28:46", "0:28:47", "0:28:48", "0:28:49", 
"0:28:50", "0:28:51", "0:28:52", "0:28:53", "0:28:54", "0:28:55", 
"0:28:56", "0:28:57", "0:28:58", "0:28:59", "0:29:00", "0:29:01", 
"0:29:02", "0:29:03", "0:29:04", "0:29:05", "0:29:06", "0:29:07", 
"0:29:08", "0:29:09", "0:29:10", "0:29:11", "0:29:12", "0:29:13", 
"0:29:14", "0:29:15", "0:29:16", "0:29:17", "0:29:18", "0:29:19", 
"0:29:20", "0:29:21", "0:29:22", "0:29:23", "0:29:24", "0:29:25", 
"0:29:26", "0:29:27", "0:29:28", "0:29:29", "0:29:30", "0:29:31", 
"0:29:32", "0:29:33", "0:29:34", "0:29:35", "0:29:36", "0:29:37", 
"0:29:38", "0:29:39", "0:29:40", "0:29:41", "0:29:42", "0:29:43", 
"0:29:44", "0:29:45", "0:29:46", "0:29:47", "0:29:48", "0:29:49", 
"0:29:50", "0:29:51", "0:29:52", "0:29:53", "0:29:54", "0:29:55", 
"0:29:56", "0:29:57", "0:29:58", "0:29:59", "0:30:00"), class = "factor"), 
    student = c("bob", "bob", "bob", "bob"), somemeasure = c(0L, 
    0L, 1L, 1L)), .Names = c("somedata$Time", "student", "somemeasure"
), row.names = c(NA, 4L), class = "data.frame")
4

1 回答 1

2

假设您的数据框名为df. 首先,通过将任意日期和原始列粘贴在一起Time,然后使用as.POSIXct().

然后使用函数scale_x_datetime()为您想要查看的标签设置中断和格式。

df$Time2<-as.POSIXct(paste("1960-01-01 ",df$Time))
library(scales)
ggplot(df,aes(Time2,somemeasure))+geom_point()+
  scale_x_datetime(breaks=date_breaks("30 sec"),labels = date_format("%M:%S"))
于 2013-06-27T15:34:44.247 回答