2
州の地図を作成しようとしています。郡は輪郭が描かれています。リゾート。ああ、私は郡を着色したり、特定のポイントを追加するのに問題があります。私のコードは、http://eriqande.github.io/rep-res-web/lectures/making-maps-with-R.htmlから の洞察を得てありがとうございます!特定の郡とRのポイントを強調表示する状態マップを作成する(ggmaps、maps、ggplot2)
library(ggplot2)
library(ggmap)
library(maps)
library(mapdata)
states <- map_data("state")
dim(states)
ut_df <- subset(states, region == "utah")
head(ut_df)
counties <- map_data("county")
ut_county <- subset(counties, region == "utah")
head(ut_county)
ut_base <- ggplot(data = ut_df, mapping = aes(x = long, y = lat, group =
group)) +
coord_fixed(1.3) +
geom_polygon(color = "black", fill = "gray")
ut_base + theme_nothing() +
geom_polygon(data = ut_county, fill = NA, color = "white") +
geom_polygon(color = "black", fill = NA) # get the state border back on top
ありがとうございます!これはまさに私がやろうとしていたものです:) – James