我一直在看ggplot2书中5.10章节的geom_rect示例,但不明白在aes函数中NULL的用途。举个例子,在使用mpg数据集时:
g = ggplot(data=mpg, aes(x=displ, y=hwy)) + geom_point()
#Produces a plot with a transparent filled region
g + geom_rect(aes(NULL, NULL), alpha=0.1,xmin=5, xmax=7, ymin=10,
ymax=45, fill="blue")
#Solid filled region (v0.9) or nothing in v0.8
g + geom_rect(alpha=0.1,xmin=5, xmax=7, ymin=10, ymax=45, fill="blue")
我理解的是,这些 NULL 值正在重置 x 和 y 的映射,但我不明白为什么这会影响透明度。
geom_rect
对我来说一直像巫术一样(我能够可靠地让它工作的唯一方法是始终将其自己的数据框传递给它)。 - joranNULL
是什么意思? - csgillespieannotate
代替。 - hadley