考虑下图(数据来自有用的链接:How to create custom date labels using ggplot with scale_x_date)
start_date <- as.Date('2020-08-08')
end_date <- as.Date('2021-05-10')
# tibble with test data
df <- tibble( dates = as.Date(as.character(seq(start_date, end_date, by = 4) ) ),
yval = as.numeric(strftime(dates, format = "%d")),
# following two lines just to give some color to the plot
month = strftime(dates, format = "%m") ) %>%
group_by( month )
df
ggplot(df, aes( x=dates, y=yval, color = month ) ) +
geom_point() +
scale_x_date(date_labels = "%b %d", breaks = "1 month")
我想要的是NOT,2,4,6,...X轴上的标签.
我try 了"2个月"的休息,但它起到了相反的作用,删除了第1,3D,5,...标签.
有什么 idea 可以做到这一点(最好不用手动逐个指定标签)