Skip to content

Instantly share code, notes, and snippets.

@hrpunio
Created December 25, 2021 12:48
Show Gist options
  • Save hrpunio/007710a904279496fa7931e50e712388 to your computer and use it in GitHub Desktop.
Save hrpunio/007710a904279496fa7931e50e712388 to your computer and use it in GitHub Desktop.
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