r ggplot小时格式x轴并减少刻度间隔

时间:2015-11-11 22:28:48

标签: r ggplot2 datetime-format

我想在一组情节中绘制一些参数的时间序列。 x轴非常密集。

ggplot(Tur_flow, aes(x=time, group=parameter, colour=parameter)) 
  + geom_point(aes(y=value), size=2) + geom_line(aes(y=value), size=1) 
  + stat_smooth(aes(y=value), method=lm, se = TRUE) 
  + facet_grid(parameter ~ Section, scale="free") 
  + theme(text = element_text(size=20), axis.text.x=element_text(angle=45),    
        legend.position="bottom") + theme_minimal()[1]

dput(head(Tur_flow))
structure(list(Section = structure(c(2L, 2L, 2L, 2L, 2L, 2L), .Label = c("S-5", "S-50", "S+5", "S+50"), class = "factor"), parameter = structure(c(3L, 
3L, 3L, 3L, 3L, 3L), .Label = c("Discharge", "Mean_Velocity", 
"T_15", "T_25", "T_65", "Water_Depth"), class = "factor"), time = structure(c(6L, 13L, 20L, 27L, 34L, 41L), .Label = c("11:59:55", "11:59:56", 
"11:59:58", "11:59:59", "12:00:00", "12:00:02", "12:00:05", "12:00:55", 
"12:00:56", "12:00:58", "12:00:59", "12:01:00", "12:01:01", "12:01:05", 
"12:01:55", "12:01:56............. "8.30", "8.31", "8.41", "8.54", "8.94", "800.31", "822.01", "828.77", "839.30", "846.11", "847.60", "8497.25", "894.21", "91.66", "91.67", "91.68", "91.90", "92.08", "92.23", "92.54", "93.23", "974.50", "N/A"), class = "factor")), .Names = c("Section", "parameter", 
"time", "value"), row.names = c(NA, 6L), class = "data.frame")`

enter image description here

如何缩短间隔以更好地查看标签。 “时间”栏的格式为“12:01:55”,或者可能是“07/10/2014 12:01:55”。哪种格式兼容绘图?

0 个答案:

没有答案