componentDidMount
2020年1月1日之后还有很大的差距,我不希望那样。尽管休息已经完成了我想要的,但是这些差距如何消除这些差距?我试过了scale_y_date的所有参数,但是没有运气。谁能帮我这个?
答案 0 :(得分:1)
没有数据,我无法复制所需的确切图像,但是如果将日期保留为字符,则可以删除图形中的多余空间。带有一些伪数据:
DATA <- data.frame(CASES_CF = 1:21,
Date = c("2020-01-30","2020-02-02","2020-02-03","2020-02-10",
"2020-03-01","2020-03-03","2020-03-04","2020-03-05",
"2020-03-06","2020-03-07","2020-03-08","2020-03-09",
"2020-03-10","2020-03-11","2020-03-12","2020-03-13",
"2020-03-14","2020-03-15","2020-03-16","2020-03-17",
"2020-03-18"))
ddd <- c("2020-01-30","2020-02-02","2020-02-03","2020-02-10","2020-03-01","2020-03-03",
"2020-03-04","2020-03-05","2020-03-06","2020-03-07","2020-03-08","2020-03-09",
"2020-03-10","2020-03-11","2020-03-12","2020-03-13","2020-03-14","2020-03-15",
"2020-03-16","2020-03-17","2020-03-18")
ddd <- factor(ddd)
ddd
ggplot(DATA, aes(CASES_CF, Date)) + scale_y_discrete(breaks = ddd) + geom_point()
如果您决定将日期格式转换为其他格式(例如20年3月18日),则最好转换为因数并使用该功能设置级别。