【发布时间】:2020-02-08 21:55:18
【问题描述】:
我正在尝试使用 scale_x_continuous 更改基于日期的 x 轴的比例限制,但 ggplot2 不会接受我的新限制。
示例::
mydata <- tibble::tibble(
x = as.Date(c("2020-01-01", "2020-01-02", "2020-01-03", "2020-01-04", "2020-01-05")),
y = 1:5
)
mydata_sub <- mydata[2:4,]
g <- ggplot2::ggplot(mydata_sub, ggplot2::aes(x = x, y = y)) +
ggplot2::geom_point()
g <- g + ggplot2::scale_x_continuous(limits = c(min(mydata$x), max(mydata$x)))
print(g)
这会导致错误信息:
Error in as.Date.numeric(value) : 'origin' must be supplied
我是否使用了错误的scale_ 函数?
【问题讨论】: