【发布时间】:2022-01-19 20:28:31
【问题描述】:
嗨,这是我的 R 脚本的最后一部分我在地图上有点我希望能够将点更改为不同的颜色以反映组织,并在我的地图上添加一个图例来反映不同的组织
我的数据标题是
组织代码,组织名称,长,纬度
ggplot() +
geom_polygon(data = worldmap,
aes(x = long, y = lat,
group = group),
fill = 'gray90',
color = 'black') +
coord_fixed(ratio = 1.3,
xlim = c(-10,3),
ylim = c(50, 59)) +
theme_void() +
geom_point(data = Data, aes(x = long, y = lat))
【问题讨论】:
-
如果你想为你的点着色,你必须在
coloraes 上映射包含组织名称或类型的列,即geom_point(..., aes(..., color = ORGANIZATION))。这将自动添加一个图例。参见例如stackoverflow.com/questions/64888609/… 使用不同 shaqpes 的示例 -
当我像这样编写脚本时,我只剩下一个带有色点的组织列表,但地图不见了 ggplot() + geom_polygon(data = worldmap, aes(x = long, y = lat , group = group), fill = 'gray90', color = 'black') + coord_fixed(ratio = 1.3, xlim = c(-10,3), ylim = c(50, 59)) + theme_void() + geom_point (data = Data, aes(x = long, y = lat,color = Provider))