adding an annotation works only if global aesthetics have been defined in ggplot().
If there are only "local" aesthetics in individual geoms the annotation will not be drawn (no warning though).
library(ggplot2)
library(grid)
df<-data.frame(x=1:10, y=1:10)
anno<- annotation_custom(grid.rect(draw=FALSE), xmin=7, xmax=10,ymin=1, ymax=2)
## Global aesthetics: works fine
ggplot(df, aes(x=x, y=y)) + geom_point()+anno## "Local" aesthetics: does not work
ggplot() + geom_point(data=df, aes(x=x, y=y))+anno
I tried setting scales and/or coord limits explicitly, but this doesn't make it work either:
Add to news
Fix inherit.aes so dummy data is not called out
Define and use dummy_data() to assign data to annotation layers
Add tests for dummy data and inherit.aes
Hi,
adding an annotation works only if global aesthetics have been defined in
ggplot()
.If there are only "local" aesthetics in individual geoms the annotation will not be drawn (no warning though).
I tried setting
scales
and/orcoord
limits explicitly, but this doesn't make it work either:The text was updated successfully, but these errors were encountered: