Pie charts with ggplot in R and pd.plot in Python

14 Aug 2019

df <- data.frame(
  variable = c("Yet to eat", "Eaten"),
  value = c(20, 80)
)
	
ggplot(df, aes(x = "", y = value, fill = variable)) +
  geom_col(width = 2) +
  scale_fill_manual(values = c("grey", "blue")) +
  coord_polar("y", start = pi / 3) +
  labs(title = "Happy Pi(e) Day")
df = pd.DataFrame([8,2], 
        index=['Eaten', 'To Be Eaten'], 
        columns=['x'])
df.plot(kind='pie', subplots=True, figsize=(6, 6))
[ R  function  python  plot  ]