【发布时间】:2021-12-13 22:11:17
【问题描述】:
我正在绘制从 16:00 到 06:00 夜间收集的数据的风速与时间的关系图。我希望图表连续显示这些时间,从 16:00 到 06:00,午夜更靠近 x 轴的中心。我当前的图表以中午为中心。
这是我目前的图表:
代表代码:
wind_speed <- structure(list(time_start = structure(c(0, 3600, 7200, 10800,
14400, 18000, 21600, 57600, 61200, 64800, 68400, 72000, 75600,
79200, 82800), class = c("hms", "difftime"), units = "secs"),
wind_avg = c(1.60133333333333, 1.54866666666667, 0.900666666666667,
1.28766666666667, 1.78533333333333, 0.678666666666667, 1.00733333333333,
0.531, 0.821666666666667, 0.119666666666667, 0.401333333333333,
0.501333333333333, 0.769333333333333, 1.797, 1.52266666666667
), time_of_day = c("00:00", "01:00", "02:00", "03:00", "04:00",
"05:00", "06:00", "16:00", "17:00", "18:00", "19:00", "20:00",
"21:00", "22:00", "23:00")), row.names = c(NA, -15L), class = c("tbl_df",
"tbl", "data.frame"))
library(ggplot2)
ggplot(data = wind_speed, aes(x = time_start, y = wind_avg))+
geom_point()
谢谢!
【问题讨论】:
标签: r datetime ggplot2 axis-labels