我正在绘制一个使用geom_segment表示事件时间的ggplot图。如何使x轴标签恢复为HH:MM:SS格式?
DB[,.(TM, PF)] %>% ggplot(aes(x = TM, xend = TM)) +
geom_segment(y = -Inf, yend = Inf, colour = (DB$PF+1)) +
scale_x_time(limit = c(min(DB$TM), max(DB$TM)))
# TM PF
#1: 2019-09-02 13:32:01 0
#2: 2019-09-02 13:32:01 0
#3: 2019-09-02 13:15:38 0
#4: 2019-09-02 13:15:41 0
#5: 2019-09-02 13:15:34 0
我尝试过geom_segment(..., label = as.factor(DB$TM))
,但是却出现了错误Error in f(..., self = self) : Breaks and labels are different lengths
。
感谢建议