在 geom_line
图中获得奇怪的顶点排序 . 左手图是基础R;右边是ggplot .
这是我正在使用的shapefile . 这将重现情节:
require(ggplot2); require(maptools)
rail = readShapeLines('railnetworkLine.shp')
rail_dat = fortify(rail[1,])
ggplot(rail_dat) + geom_line(aes(long, lat, group=group)) + coord_equal()
知道是什么导致了这个吗?强化的数据顺序似乎是正确的,因为单独绘制 lines()
确认 .
1 回答
使用
geom_path
而不是geom_line
.geom_line
在绘图之前将数据从最低x值(在这种情况下为long
)排序,但geom_path
以数据帧行的当前顺序绘制数据 .