我正在尝试用十六进制颜色对我的地图进行颜色编码。越南、菲律宾、印度尼西亚:十六进制 - #404E57 蒙古、巴基斯坦、孟加拉国、缅甸、斯里兰卡:十六进制 - #A0A7AB。我希望其他国家/地区为灰色,并且仅列出的国家/地区采用相应的颜色编码。我应该添加哪行代码来做到这一点,因为我是 ggplot 地图的新手。感谢您的时间。
这是我的代码:
ia_countries = read_csv('country_ia_3.csv') %>%
mutate(iso_a3 = countrycode(sourcevar = country, origin = 'country.name', destination = 'iso3c'))
ip_map = ne_countries(scale = "medium", returnclass = "sf") %>%
right_join(ia_countries, by = "iso_a3")
ggplot() +
geom_sf(data = ne_countries(scale = "medium", returnclass = "sf"), fill = 'grey95', colour = 'grey40') +
geom_sf(data = ip_map, colour = 'grey40') +
coord_sf(xlim = c(60,140), ylim = c(-15,50)) +
labs(x = NULL, y = NULL) +
geom_label_repel(data = ia_countries, aes(
x = long,
y = lat,
label = country
)) +
theme_minimal() +
theme(
panel.grid = element_blank(),
axis.text.x = element_blank(),
axis.text.y = element_blank(),
legend.position = "bottom"
)