Skip to content

Instantly share code, notes, and snippets.

@sneakers-the-rat
Created August 23, 2022 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sneakers-the-rat/8491c7c1ffdf0d9ec5dd8d6f20d4a439 to your computer and use it in GitHub Desktop.
Save sneakers-the-rat/8491c7c1ffdf0d9ec5dd8d6f20d4a439 to your computer and use it in GitHub Desktop.
pie charts in ggplot2
library(ggplot2)
data <- data.frame(
months=c("jan", 'feb', 'mar', 'apr', 'may', 'june', 'july', 'august', 'sept', 'oct', 'nov', 'dec'),
days=c(31,28,31,30,31,30,31,31,30,31,30,31),
values=seq(12)
)
g.pie <- ggplot(data, aes(x='', y=days, fill=values)) +
geom_col()+
scale_fill_distiller(
palette="RdBu",
limits=c(
-1*max(abs(values)),
max(abs(values)))
)+
coord_polar(theta="y")
g.pie
ggsave('myplot.pdf', g.pie)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment