为什么 annotation_raster 不起作用?

xzh*_*zhu 5 r ggplot2

在文档中,有一个示例显示了annotation_raster如下用法。

ggplot(aes(x=mpg, y=wt), data=mtcars) +
  annotation_raster('red', -Inf, Inf, -Inf, Inf) +
  geom_point()
Run Code Online (Sandbox Code Playgroud)

这工作正常,但是,当我将数据和 aes 移动到图层中时,突然它不再起作用了:

ggplot() +
  annotation_raster('red', -Inf, Inf, -Inf, Inf) +
  geom_point(aes(x=mpg, y=wt), data=mtcars)  # doesn't work
Run Code Online (Sandbox Code Playgroud)

这令人困惑,因为对我来说这两个在语义上是相同的。

是否有第二行不起作用的原因,有没有一种方法可以annotation_raster在基础层早期不指定数据和 aes 的情况下使用?