感谢本网站上一些用户的帮助,我能够使用 geom_point 获得一些数据的漂亮地图。 (获得州界的边界)但是,现在我正在尝试清理它,因为我有更多年的时间来绘制,并希望确保情节正常工作并提供良好的信息。经过进一步的研究,似乎 geom_tile 实际上会更好,因为它会避开点并使用渐变。
我遇到的问题是让代码与 geom_tile 一起使用。它没有任何情节,我也不知道为什么。
这是数据集:
https://www.dropbox.com/s/0evuvrlm49ab9up/PRISM_1895_db.csv?dl=0
这是 geom_points 的原始代码:
PRISM_1895_db <- read.csv("/.../PRISM_1895_db.csv")
regions<- c("north dakota","south dakota","nebraska","kansas","oklahoma","texas","minnesota","iowa","missouri","arkansas", "illinois", "indiana", "wisconsin")
ggplot() +
geom_polygon(data=subset(map_data("state"), region %in% regions), aes(x=long, y=lat, group=group)) +
geom_point(data = PRISM_1895_db, aes(x = longitude, y = latitude, color = APPT), alpha = .5, size = 3.5) +
geom_polygon(data=subset(map_data("state"), region %in% regions), aes(x=long, y=lat, group=group), color="white", fill=NA)
![enter image description here](https://i.stack.imgur.com/2SqkE.png)
这是我一直在尝试的代码,但没有显示任何数据。
ggplot() +
geom_polygon(data=subset(map_data("state"), region %in% regions), aes(x=long, y=lat, group=group)) +
geom_tile(data = PRISM_1895_db, aes(x = longitude, y = latitude, fill = APPT), alpha = 0.5, color = NA)
geom_polygon(data=subset(map_data("state"), region %in% regions), aes(x=long, y=lat, group=group), color="white", fill=NA)
![enter image description here](https://i.stack.imgur.com/UcSGH.png)