我使用scale_x_continuous
来缩小ggplots上的超前/滞后空间。它适用于数字x轴对象。但是,约会却没有喜悦。
我的例子:
library(lubridate)
library(tidyverse)
# this works
ggplot(cars, aes(x = speed, y = dist)) +
geom_line() +
scale_x_continuous(expand = c(0, 0))
# this does not work
cars %>%
mutate(date = seq(dmy("01/01/2019"), dmy("01/01/2019") + ddays(nrow(cars) - 1), "day")) %>%
ggplot(aes(x = date, y = dist)) +
geom_line() +
scale_x_continuous(expand = c(0, 0))
有什么想法吗?