在ggplot中绘制年度数据

时间:2019-04-19 20:16:20

标签: r ggplot2

我在使X轴正确绘制数据出现的“年”时遇到一些麻烦,但是似乎绘制了“时间”。

Time_Plot <- Glass_DB %>%
  mutate(`Date & Time In Hour` = yday(`Date & Time In Hour`)) %>% 
  ggplot(aes(x = `Date & Time In Hour`)) +
  geom_histogram(bins = 50, colour = "white", fill = "#1380A1") + 
  labs(title = "Glass Category Orders",
       subtitle = "Jobs by Day of Year") + 
  scale_x_time() + bbc_style()
Time_Plot

enter image description here

样本数据集:

 structure(c(1554973200, 1554811200, 1554811200, 1554811200, 1554793200, 
1554732000), class = c("POSIXct", "POSIXt"), tzone = "UTC")

Date & Time In Hour
3/23/2019 11:00
3/7/2019 16:00
2/25/2019 13:00
3/27/2019 13:00
3/28/2019 11:00
3/13/2019 8:00
3/8/2019 9:00
3/20/2019 13:00
3/29/2019 10:00
3/12/2019 15:00
4/1/2019 10:00

更新:--------------------------------------------- -----

已删除scale_x_time()以更正时间问题。有没有一种方法可以在X轴上显示月份,从而使图表更具可读性。

enter image description here

0 个答案:

没有答案