从wrld_Simp全球地图中删除南极洲
我在ggplots中使用wrld_Simp作为背景,并希望删除南极洲。但我不知道怎么做。谢谢你的帮助从wrld_Simp全球地图中删除南极洲,r,ggplot2,raster,R,Ggplot2,Raster,我在ggplots中使用wrld_Simp作为背景,并希望删除南极洲。但我不知道怎么做。谢谢你的帮助 library(maptools) data("wrld_simpl") plot(wrld_simpl) wrld_simpl[wrld_simpl@data$ISO3 != "ATA"] 脚本示例: library(ggplot2) p <- ggplot() + geom_polygon(data = wrld_simpl, aes(x = long, y = lat, gr
library(maptools)
data("wrld_simpl")
plot(wrld_simpl)
wrld_simpl[wrld_simpl@data$ISO3 != "ATA"]
脚本示例:
library(ggplot2)
p <- ggplot() +
geom_polygon(data = wrld_simpl, aes(x = long, y = lat, group = group), colour = "black", fill = "grey")
p <- p + geom_raster(data = df , aes(x = x, y = y, fill = layer))
p <- p + coord_equal() + theme_bw() + labs(x="", y="")
p <- p + scale_fill_gradientn(colours = rev(terrain.colors(10)))
p <- p + labs(list(title = ""))
p
p <- ggplot() +
geom_polygon(data = wrld_simpl[wrld_simpl@data$UN!="10",], aes(x = long, y = lat, group = group), colour = "black", fill = "grey")
p <- p + geom_raster(data = df , aes(x = x, y = y, fill = layer))
p <- p + coord_equal() + theme_bw() + labs(x="", y="")
p <- p + scale_fill_gradientn(colours = rev(terrain.colors(10)))
p <- p + labs(list(title = ""))
p
库(ggplot2)
p我没有特别使用该包,但是ggplot2::map_data()
从maps
包调用maps。然后您可以像使用任何数据帧一样使用dplyr::filter
对其进行子集划分
library(dplyr)
library(maps)
library(ggplot2)
map_data("world") %>%
filter(region != "Antarctica") %>%
ggplot(aes(long, lat, group = paste(region, group))) +
geom_polygon() +
coord_fixed()
这里有一个去除南极洲的解决方案(相应的联合国代码=10)
脚本示例:
library(ggplot2)
p <- ggplot() +
geom_polygon(data = wrld_simpl, aes(x = long, y = lat, group = group), colour = "black", fill = "grey")
p <- p + geom_raster(data = df , aes(x = x, y = y, fill = layer))
p <- p + coord_equal() + theme_bw() + labs(x="", y="")
p <- p + scale_fill_gradientn(colours = rev(terrain.colors(10)))
p <- p + labs(list(title = ""))
p
p <- ggplot() +
geom_polygon(data = wrld_simpl[wrld_simpl@data$UN!="10",], aes(x = long, y = lat, group = group), colour = "black", fill = "grey")
p <- p + geom_raster(data = df , aes(x = x, y = y, fill = layer))
p <- p + coord_equal() + theme_bw() + labs(x="", y="")
p <- p + scale_fill_gradientn(colours = rev(terrain.colors(10)))
p <- p + labs(list(title = ""))
p
p