我的数据看起来像这样,周数介于2018-03-25到2018-12-23之间:
周儿童n频率 1 2018-03-25 FALSE 758 0.812 2 2018-03-25 TRUE 176 0.188 3 2018-04-01 ……
正如上面提到的@kath,你可以使用的功能 scale_x_date() :
scale_x_date()
library(tidyverse) dat %>% ggplot(aes(week, freq, fill = child)) + geom_area(position = "stack") + scale_fill_manual(values = c("#006FB7", "#F18E00"), labels = c("Adults", "Children")) + scale_x_date( "Date", breaks = seq(min(dat$week), max(dat$week), by = "month"), date_labels = "%b, %Y", ) + scale_y_continuous("Frquency", labels = scales::percent) + ggthemes::theme_tufte()