With version 2.0.0, ggplot2
has gained a new geometry, geom_blank() which draws nothing.
It can be used to avoid this type of errors when it is placed as last layer.
plot <- ggplot(data, aes(x, y)) +
geom_point() +
#aes(alpha=0.3,color=scale) +
#scale_color_gradient(high="red") +
geom_blank()
Using geom_blank()
in this way is similar to the workaround in @krlmlr's answer which uses list()
as last layer.