我有一个名为Completed的数据框,看起来像这样:
X1纬度经度守恒1 40 -8是的2 -5 10没有3 20 30是的4 …
简答:使用 aes(color = Conservation) 代替 for 环。
aes(color = Conservation)
for
完整解决方案
Completed <- tribble( ~X1, ~Latitude, ~Longitude, ~Conservation, 1, 40, -8, "Yes", 2, -5, 10, "No", 3, 20, 30, "Yes", 4, 5, -10, "No" ) world <- map_data("world") gg1 <- ggplot() + geom_polygon(data = world, aes(x=long, y = lat, group = group)) + coord_fixed(1.3) gg1 + geom_point(aes(x = Longitude, y = Latitude, color = Conservation), data = Completed, size = 2) + scale_color_manual(values = c("pink", "yellow"))