Created
December 25, 2021 12:48
-
-
Save hrpunio/007710a904279496fa7931e50e712388 to your computer and use it in GitHub Desktop.
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") | |
library("ggpubr") ## for ggarrange | |
library("dplyr") | |
df <- data.frame( | |
ab = c(10, 10, 10, 20, 15, 20), | |
as = c(12, 15, 18, 18, 12, 30), | |
branch = c('S', 'M', 'D', 'CS', 'IT', 'A') | |
) | |
df <- df %>% pivot_longer(cols=c(ab, as), names_to='budget', values_to='v') | |
p1 <- df %>% | |
ggplot(aes(x = branch, y=v, fill=budget )) + | |
geom_bar(alpha=.25, stat = 'identity', position="dodge" ) + | |
xlab(label="") + | |
ylab(label="") + | |
ggtitle("Plot1") + | |
coord_polar(start = 3*pi/2) | |
p1 | |
p2 <- df %>% | |
ggplot(aes(x = branch, y=v, fill=budget)) + | |
geom_bar(alpha=.25, stat = 'identity', position="identity" ) + | |
xlab(label="") + | |
ylab(label="") + | |
ggtitle("Plot2") + | |
coord_polar(start = 3*pi/2) | |
p2 | |
p12 <- ggarrange(p1, p2, ncol = 2, nrow = 1) | |
ggsave(plot=p12, file='polar_bars.png') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment