Skip to content

Instantly share code, notes, and snippets.

@avilella
Created March 3, 2015 11:27
Show Gist options
  • Save avilella/c5adf14c6d1ebc685722 to your computer and use it in GitHub Desktop.
Save avilella/c5adf14c6d1ebc685722 to your computer and use it in GitHub Desktop.
ggplot2 polar
library(ggplot2)
gr1 <- c(0, 5, 15, 20, 30, 40)
gr3 <- c(0, 5, 10, 25, 40, 60, 80)
gr2 <- c(0, 15, 25, 30, 40)
df2<- data.frame (pos = c(gr1, gr2, gr3), group = c(rep(1, length(gr1)),
rep(2, length(gr2)), rep(3, length(gr3))))
df2$cpos <- cumsum (df2$pos)
cx <- ggplot(df2, aes(fill = factor(group), x = cpos))
cx + geom_bar(width = 1, colour = "black", position = "dodge") + coord_polar()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment