Placing a boundary around a series of points in gg

2019-04-09 18:51发布

问题:

I have a series of points that I want to place a boundary around. How can I go about this?

These are my points:

I tried geom_line but that was obviously wrong since it produced this!

Thanks

回答1:

Use geom_path instead of geom_line. Here is an example:

i <- seq(0, 2*pi, length.out=50)
dat <- data.frame(x=cos(i), y=sin(i))

library(ggplot2)
ggplot(dat, aes(x, y)) + geom_line()

ggplot(dat, aes(x, y)) + geom_path()