我需要创建一个欧洲地图来显示各个国家/地区的变量分布。我需要黑白地图。我以ggplot
为依据,并以此为例说明了这个approach。我改变了基于this blogpost的传说。这一切工作正常与这个结果:geom_polygon中的纹理填充
我的问题是如何更改地图的方式,我缺少填充信息和显示为纯白色的国家有纹理超过他们(我是思考对角线)?
因为我的剧本是有点乱,我只显示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图的低值很重要。鉴于我不得不依靠黑与白,我提出了使用纹理的想法,但我愿意接受其他建议。
谢谢!
恐怕纹理可能无法与'ggplot2',以下哈德利的答案[这个相关的问题](https://stackoverflow.com/a/2901210/4550695)。虽然这已经很老了,所以也许现在已经实现了! –
关于这个问题,我认为你并没有真正需要将纹理分隔开,没有数据的国家。对于变量值较低的国家来说,它们已经是纯白的灰色边框,与浅灰色和黑色边框形成鲜明对比。剧情看起来不错! –