Created
August 23, 2022 00:20
-
-
Save sneakers-the-rat/8491c7c1ffdf0d9ec5dd8d6f20d4a439 to your computer and use it in GitHub Desktop.
pie charts in ggplot2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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