Skip to content

Instantly share code, notes, and snippets.

@juliuskittler
Last active October 27, 2019 11:30
Show Gist options
  • Select an option

  • Save juliuskittler/397e9a209804c7773c788a0b3bf4db07 to your computer and use it in GitHub Desktop.

Select an option

Save juliuskittler/397e9a209804c7773c788a0b3bf4db07 to your computer and use it in GitHub Desktop.
df = ggplot2::diamonds # data frame with 1 character/factor variable
ggplot(data = df, aes(x = cut, fill = color)) +
geom_bar(position = "stack", alpha = 0.8) + # alternative: position = "dodge"
labs(title = "Number of Diamonds by Cut and Color", y = "Count", x = "Cut") +
theme_bw() + theme(plot.title = element_text(hjust = 0.5))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment