我有这个代码生成这张地图:
library(ggmap)
library(mapdata)
counties <- map_data("county")
iowa_counties <- subset(counties, region=="iowa")
sq_map2 <- get_map(location = c(-92.55191,42.89219), maptype = "satellite", source = "google", zoom = 9)
ggmap(sq_map2) +
scale_y_continuous(limits=c(42.51118, 43.26184), expand=c(0,0)) +
scale_x_continuous(limits=c(-93.0735, -92.03318), expand=c(0,0)) +
geom_polygon(data = iowa_counties, aes(x=long, y=lat, group=group), fill = NA, color = "white")
如您所见,左上角有一个额外的三角形。我怎么能摆脱它?
答案 0 :(得分:0)
一种非常简单的方法是减少y极限的最大值以去除该上部点并防止构造三角形。只需将617
中的值从scale_y_continuous
更改为43.26184
即可:
43.25184
当然,您也可以在library(ggmap)
library(mapdata)
counties <- map_data("county")
iowa_counties <- subset(counties, region=="iowa")
sq_map2 <- get_map(location = c(-92.55191,42.89219), maptype = "satellite", source = "google", zoom = 9)
ggmap(sq_map2) +
scale_y_continuous(limits=c(42.51118, 43.26184), expand=c(0,0)) +
scale_x_continuous(limits=c(-93.0735, -92.03318), expand=c(0,0)) +
geom_polygon(data = iowa_counties, aes(x=long, y=lat, group=group), fill = NA, color = "white")
中过滤掉某个纬度以上的点。