Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R中地图投影中不需要的水平线_R_Ggplot2 - Fatal编程技术网

R中地图投影中不需要的水平线

R中地图投影中不需要的水平线,r,ggplot2,R,Ggplot2,几行代码来暴露我的问题。当我使用地图时 世界和我介绍了一个投影,我总是以一些 奇怪的水平线。 请看一看 从这里我举了新泽兰的例子 library(ggplot2) nz <- map_data("nz") # Prepare a map of NZ nzmap <- ggplot(nz, aes(x = long, y = lat, group = group)) + geom_polygon(fill = "white", colour = "black") # Plot i

几行代码来暴露我的问题。当我使用地图时 世界和我介绍了一个投影,我总是以一些 奇怪的水平线。 请看一看

从这里我举了新泽兰的例子

library(ggplot2)

nz <- map_data("nz")
# Prepare a map of NZ
nzmap <- ggplot(nz, aes(x = long, y = lat, group = group)) +
geom_polygon(fill = "white", colour = "black")

# Plot it in cartesian coordinates
nzmap
# With correct mercator projection
nzmap + coord_map()
库(ggplot2)

nz这是ggplot中非常常见的问题,但令人高兴的是,它很容易解决:


世界地图+合作地图(xlim=c(-180180))
产生


解决方案来源:

请发布图片。此外,不能将https://与该链接一起使用,因为其证书无效。据了解,这是一个已知的问题,但没有计划修复它,因为创建者更倾向于使用更好的数据源
world <- map_data("world")
# Prepare a map of the world
worldmap <- ggplot(world, aes(x = long, y = lat, group = group)) +
geom_polygon(fill = "white", colour = "black")

# Plot it in cartesian coordinates
worldmap

##but the following is a disaster!
# With correct mercator projection
worldmap + coord_map()