我可以在ggplot2中更改背景地图吗?

Ped*_*ooh 2 plot r ggplot2

我只是在R中玩ggplot2,语法就像

geom_map(data=world, map=world
aes(x=long, y=lat, map_id=region),
color="white", fill="#7f7f7f", size=0.05, alpha=1/4)
Run Code Online (Sandbox Code Playgroud)

这给了我世界地图,是否有可能只将英国地图作为背景地图?非常感谢Peddie

hrb*_*str 8

你也可以这样做:

library(ggplot2)
library(ggthemes)
library(raster)
library(rgeos)

gbr <- getData("GADM", country="GBR", level=0)
gbr <- gSimplify(gbr, 0.01)

gbr_map <- fortify(gbr)

gg <- ggplot()
gg <- gg + geom_map(map=gbr_map, data=gbr_map,
                    aes(x=long, y=lat, map_id=id),
                    fill="#7f7f7f")
gg <- gg + coord_map()
gg <- gg + theme_map()
gg
Run Code Online (Sandbox Code Playgroud)

一旦我的ggalt包装在CRAN中,你甚至可以使用一个不错的投影.

在此输入图像描述

  • 通过查看带有标记刻度的地图(即带有#的纬度/经度线) (2认同)