# A pie chart = stacked bar chart + polar coordinates
pie <- ggplot(mtcars, aes(x = factor(1), fill = factor(cyl))) +
geom_bar(width = 1)
pie + coord_curvedpolar(theta = "y")
# Demonstrating curved category labels
p <- ggplot(data.frame(x = paste("Category label", 1:5), y = runif(5)),
aes(x, y, fill = x)) +
geom_col() +
theme_bw() +
theme(panel.border = element_blank(),
legend.position = "none",
axis.text.x = element_text(size = 10, vjust = 0.5))
# Standard bar chart in Cartesian Co-ordinates
p
# Standard coord_polar axis labels
p + coord_polar()
# Curved polar co-ordinate labels
p + coord_curvedpolar()
Run the code above in your browser using DataLab