在文档中,有一个示例显示了使用annotation_raster
如下。
ggplot(aes(x=mpg, y=wt), data=mtcars) +
annotation_raster('red', -Inf, Inf, -Inf, Inf) +
geom_point()
这工作正常,但是,当我将数据和 aes 移动到图层中时,突然它不再工作了:
ggplot() +
annotation_raster('red', -Inf, Inf, -Inf, Inf) +
geom_point(aes(x=mpg, y=wt), data=mtcars) # doesn't work
这很令人困惑,因为对我来说,这两者在语义上似乎是相同的。
第二行不起作用有什么原因吗?有没有办法使用annotation_raster
没有在基础层早期指定数据和 aes?