Skip to content

Instantly share code, notes, and snippets.

@allenaven
Created June 30, 2014 22:13
Show Gist options
  • Save allenaven/045eacdee83ab6f66c11 to your computer and use it in GitHub Desktop.
Save allenaven/045eacdee83ab6f66c11 to your computer and use it in GitHub Desktop.
Plot circular with R and ggplot2
# The circular conversion/transformation:
library(circular)
library(ggplot2)
k <- rad(360)
u <- runif(100000, 0, 359)
x <- cos(rad(u) * 2 * pi) / k
y <- sin(rad(u) * 2 * pi) / k
ggplot(data=data.frame(x=x, y=y), aes(x, y)) + geom_point(position='jitter')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment