Skip to content

Instantly share code, notes, and snippets.

@sckott
Created December 24, 2011 00:11
Show Gist options
  • Save sckott/1515754 to your computer and use it in GitHub Desktop.
Save sckott/1515754 to your computer and use it in GitHub Desktop.
Simple ggplot2 pie chart function.
piechart <- function(set) {
ggplot(dat[dat$type==set,], aes(x = "", y = pageviews, fill = name)) +
theme_bw() +
geom_bar(width = 1) +
coord_polar(theta = "y") +
labs(y="", x='') +
opts(panel.border = theme_rect(colour = 'white'),
axis.text.x = theme_text(colour='white'))
}
# Where dat is our data.frame, and set is the level of a factor in a column called 'type' that you want to plot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment