[英]how to specify x-axis value for date in R
我想弄清楚呼叫数量何时急剧增加。
这是我的原始代码:
plot(breaks, cumfreq0, main="Cumulative percentage of calls happened in NOV.7th", xlab="time", ylab = "cumulative percentage of calls", sub = "(each dot represents a single period of time on Nov.7th)")
但我认为 x 轴上的时间刻度不够具体。 我怎样才能改变它?
我尝试了几次,如下所示,但似乎代码确实适合时间对象。
请看下面,我只是用虚拟数据复制了您的示例
> df
# A tibble: 55 x 2
datetime Freq
<dttm> <int>
1 2018-11-01 12:41:57 215
2 2018-11-01 12:41:58 163
3 2018-11-01 12:47:06 225
4 2018-11-01 12:51:00 69
5 2018-11-01 12:57:37 203
6 2018-11-01 12:57:38 248
7 2018-11-01 12:57:38 58
8 2018-11-01 13:29:15 179
9 2018-11-01 13:37:45 233
10 2018-11-01 14:24:43 150
# ... with 45 more rows
以及以x轴作为时间戳的期望绘图类型的代码,您可以指定所需的格式
plot(df$datetime,df$Freq,xaxt="n")
axis.POSIXct(1, at=df$datetime, labels=format(df$datetime, "%m/%d/%Y %H:%M:%S"))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.