我需要创建一个欧洲地图来显示变量在各国之间的分布。我需要黑白的地图。我依靠
ggplot
然后是这个
approach
举个例子。我根据
this blogpost
. 所有这些都可以很好地实现这一结果:
我的问题是如何更改地图,使我缺少填充信息并显示为纯白色的国家的地图上有纹理(我想是对角线)?
由于我的脚本有点凌乱,我只在这里显示ggplot,没有数据准备部分:
require(ggplot2)
plotCoords <- read.csv("http://eborbath.github.io/stackoverflow/PlotCoords.csv")
showCoords <- read.csv("http://eborbath.github.io/stackoverflow/showCoords.csv")
ggplot() +
geom_polygon(
data = plotCoords,
aes(x = long, y = lat, group = group),
fill = "white", colour = "darkgrey", size = 0.6) +
geom_polygon(
data = showCoords,
aes(x = long, y = lat, group = group),
fill = "grey", colour = "black", size = 0.6) +
geom_polygon(
data = showCoords,
aes(x = long, y = lat, group = group, fill = sh_left),
colour = "black", size = 0.1) +
scale_fill_gradient(
low = "gray90", high = "gray0",
name = "Share of left-wing protesters",
guide = guide_colorbar(
direction = "horizontal",
barheight = unit(2, units = "mm"),
barwidth = unit(50, units = "mm"),
draw.ulim = F,
title.position = 'top',
title.hjust = 0.5,
label.hjust = 0.5
)) +
scale_x_continuous(element_blank(), breaks = NULL) +
scale_y_continuous(element_blank(), breaks = NULL) +
coord_map(xlim = c(-26, 47), ylim = c(32.5, 73)) +
theme_bw() +
theme(legend.justification = c(-0.4, 1.2), legend.position = c(0, 1))
第一个
geom_polygon
作为背景,我想我必须编辑
fill
那里显然,这对于区分无信息和变量I图的低值很重要。考虑到我不得不依赖黑白,我想出了使用纹理的想法,但我愿意接受其他建议。
谢谢