1

I have a dataset head that contains two variables x and y that represent points in the contourn of a circle. I try to draw the circle using this code

ggplot(head, aes(x=x, y=y))+geom_line()

However, the plot I get is this one enter image description here

Could you help me to fix this? I really need to use those points. Thanks.

1 Answers1

3

try using geom_path. It connects observations in data order geom_line connect observations ordered by x value.

If your data is not ordered ok, you can order it by computing angle

head <- head %>% mutate(r = atan2(y, x)) %>% arrange(r)
h1427096
  • 273
  • 1
  • 9