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.

2

1 Answer 1

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)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.