fill=..level.. 在 ggplot 中是什么意思?
我想为数据集创建一个“热图”,其中包含有关纽约市行政区拍摄的观测数据。
ggmap(nyc_map)+
stat_density2d(data = NYPD,
aes(x = Longitude, y = Latitude, fill= ..level..),
alpha=0.08,
bins=30,
geom = "polygon") +
scale_fill_gradient(low = "red", high = "green", name="Shootings level") +
scale_alpha(range = c(0, 0.08), guide = "none") +
scale_size(range = c(0,0.75)) +
ggtitle("Shootings for Boroughs")+
theme(axis.ticks = element_blank(),
axis.text = element_blank(),
legend.position="right") +
theme(plot.title = element_text(hjust = 0.5))
那么, fill=..level..
是什么意思?因为我没有枪击次数的变量,所以我有行数以及行政区的纬度和经度。 fill=..level..
应该表示枪击事件的平均值吗?
I want to create a "heating map" for a dataset, which contains obs about shooting in NYC Boroughs.
ggmap(nyc_map)+
stat_density2d(data = NYPD,
aes(x = Longitude, y = Latitude, fill= ..level..),
alpha=0.08,
bins=30,
geom = "polygon") +
scale_fill_gradient(low = "red", high = "green", name="Shootings level") +
scale_alpha(range = c(0, 0.08), guide = "none") +
scale_size(range = c(0,0.75)) +
ggtitle("Shootings for Boroughs")+
theme(axis.ticks = element_blank(),
axis.text = element_blank(),
legend.position="right") +
theme(plot.title = element_text(hjust = 0.5))
In that case, what does fill=..level..
means?? Because I don't have a variable for the number of shootings, I have the number of rows and the lat and long for Boroughs.
Should fill=..level..
mean about mean of the shootings?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
点-点符号
..some_var..
允许访问由 ggplot 计算的统计数据来构建绘图。在本例中,为二维密度的水平。相反,您可以通过stat()
提取并使用它们:查看 RStudio 社区上的相关问题The dot-dot notation
..some_var..
allows to access statistics computed by ggplot to construct the plot. In this case, the levels for the 2d-density. You can, instead, extract and use them withstat()
: see related question on RStudio community